33
votes
Returning lat and long of centroid point with GeoPandas
Ran into this problem myself. If you want the x and y as separate GeoDataFrame columns, then this works nicely:
gdf["x"] = gdf.centroid.map(lambda p: p.x)
gdf["y"] = gdf.centroid.map(lambda p: p.y)
...
19
votes
Accepted
Returning lat and long of centroid point with GeoPandas
Leaving the rest below, but the main thing was accessing the geometry properly. If iterating over rows, e.g. for index, row in zones.iterrows(): you can simply use row.geometry.centroid.x and row....
16
votes
Accepted
Convert Lon Lat to XY in Openlayers 3
When you transform you always transform pair of points:
ol.proj.transform([23.4, 42.5], 'EPSG:4326','EPSG:3857');
(this transforms from EPSG 4326 to EPSG 3857; the coordinates are [lon, lat])
15
votes
Accepted
Which projection is this data in?
Obviously the data is in UTM32 including the number of the zone. You can strip the 32 in front of your x-coord away as it is explicitely given by the provided CRS. However QGIS should be able to deal ...
15
votes
Accepted
Getting coordinates of point on mouse click using PyQGIS
You need QgsMapToolEmitPoint class to do that. Following code works well for that purpose:
from qgis.gui import QgsMapToolEmitPoint
def display_point( pointTool ):
print '({:.4f}, {:.4f})'....
12
votes
Accepted
Updating feature geometry from attribute fields in QGIS
Assuming you have chosen <geometry> field in the Update existing field drop down list, the expression you need would be:
geom_from_wkt('POINT('||"x"||' '||"y"||')')
12
votes
Adding x,y coordinates to Attribute table in QGIS
Use a built-in tool "Add X/Y fields to layer"
There you can choose a coordinate system in which you want your coordinates and add an optional field prefix.
11
votes
What coordinates Field Calculator used when given $x to get X coordinate in QGIS?
The QGIS field calculator is pretty powerful. So since the file is in EPSG:3879, it will report x and y in EPSG:3879.
I don't quite understand why you think it is reporting in EPSG:3067, perhaps you ...
11
votes
Accepted
Converting coordinates from cartesian to geodetic in QGIS
The Show coordinates in use option is for visualization purposes. It doesn't affect the expression.
You need to transform. Use this for X:
x(transform($geometry, @layer_crs, 'EPSG:4326'))
and for Y:
...
10
votes
Expression to Transform XY coordinates to LatLong in QGIS
If the layer is already georeferenced in QGIS then you can do something like this with the Field Calculator:
Expression for longitude:
x(transform($geometry, @YOUR_CRS_ID, 'EPSG:4326'))
And for ...
9
votes
Adding x,y coordinates to Attribute table in QGIS
Under assumption that you have some kind of a vector layer (such as GeoJSON or something similar) I provide an explanation on the example of a GeoJSON file that contains point features.
You didn't ...
8
votes
Accepted
Batch conversion of XY coordinates to latitude and longitude
[EDIT] The original source data is California State Plane Zone 2, i.e. EPSG:2226.
The following approach using ogr2ogr will perform a CSV to Shapefile conversion, including the coordinate ...
8
votes
Accepted
Calculating geometry for feature class with x/y and Lat/Long values in different projections?
you just need to run a cursor on it and use the projectAs() geometry method.
import arcpy
fc = r'C:\path_to\your_data\points.shp'
wgs = arcpy.SpatialReference(4326)
with arcpy.da.UpdateCursor(fc, ...
8
votes
Accepted
Data Defined Override XY offset input
The correct syntax involves the use of single quotes around the X and Y
'offset_x,offset_y'
8
votes
What coordinates Field Calculator used when given $x to get X coordinate in QGIS?
Expanding on the answer of @heikkivesanto, the expression can be made more generic as follows:
x( transform( $geometry, layer_property(@layer_id, 'crs'), 'EPSG:4326'))
This removes the need to copy ...
8
votes
Accepted
Extracting X and Y coordinates from .gpx file using QGIS?
You can do Layer... Save As... and choose the CSV output format. Choose Geometry type as POINT and Geometry as AS_XY:
Then you'll get a CSV like:
X,Y,route_fid,route_point_id,ele,time,magvar,...
8
votes
Accepted
Automatically generating coordinates of new points features and adding them to feature table in QGIS
The field calculator is used for a one-time calculation. Whenever you add features, the new records will not be populated with the new coordinates.
The proper way to do that is in the layers' ...
8
votes
Accepted
Extracting x,y coordinates from QgsGeometry: Point(x, y) using PyQGIS
As you can see, when you use print(vertex) it returns you a QgsGeometry class.
So, there are several approaches you may get x,y coordinates:
As was already mentioned in the comments you can convert ...
8
votes
Accepted
Generating x, y, coordinates within polygon/polyline with certain interval in QGIS
Grid is the correct term. If you have a line layer you need to convert it to polygon.
Create a point grid using the polygons extent with 500 m x and y spacing
Extract the points inside the polygon ...
7
votes
Convert Lon Lat to XY in Openlayers 3
I was looking for this function too, and I have found it in some of the examples on their site.
You can use ol.proj.fromLonLat([19.062072, 47.473478]).
http://openlayers.org/en/v3.13.1/apidoc/ol....
7
votes
Converting while reading a shapefile
Using ogr2ogr
The simplest way to do this is probably to just use ogr2ogr, no need for code. Something like this:-
ogr2ogr -f GeoJSON -s_srs XXXX -t_srs 4326 output.geojson input.shp
Replace XXXX ...
7
votes
Accepted
Create line from csv coordinates
To get this into a useful format as a CSV is going to take some doing.
The first step is to open the data in a text editor (like Notepad) and replace the semicolons with commas (edit>replace, or ...
7
votes
Accepted
Extracting starting and ending points from geometry column in separate columns using GeoPandas
This can make it:
import geopandas as gpd
from shapely.geometry import Point, LineString
line1 = LineString([Point(0,0), Point(-1,-1), Point(2,-3), Point(4,5)])
line2 = LineString([Point(-2,8), Point(...
6
votes
Returning lat and long of centroid point with GeoPandas
This has been made easier as of GeoPandas 0.3.0.
You can now access x and y of shapely Points inside a geopandas GeoSeries using your_GeoDataFrame.geometry.x and your_GeoDataFrame.geometry.y
(Note : ...
6
votes
Go To XY not working in ArcMap
Things that I would try in this order are:
click on another button in the same toolbar, and then click this button again. I have seen this behaviour from the Measure tool on that toolbar.
close ...
6
votes
Identify X Y coordinates of polygons and add them to the attribute table in QGIS?
The QGIS field calculator can do it with these built-in functions:
x($geometry)
y($geometry)
Make sure to create a new field of type real, with an appropriate accuracy. You can even use a virtual ...
6
votes
Accepted
Scaling more than 1000 polygons in QGIS
In QGIS you can create a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... with a SpatiaLite expression to perform the transformation that you need:
SELECT
...
6
votes
Adding x,y coordinates to Attribute table in QGIS
Possible solution by means of PyQGIS.
Let's assume there is a point layer called 'points' with its attribute table, see image below.
Proceed with Plugins > Python Console > Show Editor (Ctrl+...
6
votes
Accepted
Converting x,y coordinates (EPSG:102002) to latitude,longitude (EPSG:4326)
You can use QGIS:
Add delimited text layer
Reproject Layer
Add geometry attributes
6
votes
Importing points from CSV file with NaN as vertical separator in QGIS
You can:
Add the coordinates as a delimited text layer (Ctrl+Shift+T)
DBSSCAN clustering with Minimum cluster size = 2 and Maximum distance between points = 50. This will add the attribute CLUSTER_ID ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
xy × 192arcgis-desktop × 69
coordinates × 54
qgis × 44
latitude-longitude × 38
coordinate-system × 37
arcmap × 26
point × 19
convert × 16
csv × 13
geometry × 11
shapefile × 10
python × 9
arcgis-10.2 × 8
arcgis-pro × 8
excel × 8
arcpy × 7
arcgis-10.1 × 7
attribute-table × 7
line × 7
modelbuilder × 6
arcgis-10.3 × 6
export × 6
polygon × 5
field-calculator × 5