Tag Info

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) ...
• 2,118
Accepted

Difference between QgsPoint, QgsPointXY and QgsGeometry.fromPointXY() in PyQGIS

QgsPoint is a point class which supports Z (3D) and M values. (What are Z and M?) x, y, z, m = 10, 10, 20, 5 QgsPoint(x, y) # 2D # <QgsPoint: Point (10 10)> QgsPoint(x, y, z) # 3D # <...
• 77.3k
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})'....
• 30k

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 ...
• 16.6k
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"||')')
• 31k

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.
• 436
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: ...
• 77.3k

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 ...
• 634

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 ...
• 1,673

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 ...
• 3,377
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(...
• 10.5k

Extracting starting and ending points from geometry column in separate columns using GeoPandas

It is easier to use apply and lambda functions: import geopandas as gpd gdf = gpd.read_file(pth_line_shapefile) # Extract start and end coordinates of each linestring first_coord = gdf["geometry&...
Accepted

Extracting x,y coordinates from QgsGeometry: Point(x, y) using PyQGIS

I could get the same exception AttributeError: Traceback (most recent call last): File "C:\OSGeo4W\apps\Python39\lib\code.py", line 90, in runcode exec(code, self.locals) File "&...
• 33.3k

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....
• 193
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'
• 1,852
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 ...
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,...
• 65.1k
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' ...
• 3,126
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 ...
• 74.8k

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 ...
• 20.5k

Adding x,y coordinates to Attribute table in QGIS

A possible solution using 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+Alt+P) ...
• 33.3k

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 : ...
• 161

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 ...
• 65.2k

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 ...
• 76.7k
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 ...
• 14.6k
Accepted

Exporting x,y coordinates as latitude,longitude in QGIS

Before exporting there are several more steps have to be applied. Step 1. Create two additional fields, i.e. "lat" and "long" via the Field Calculator Step 2. Apply the following ...
• 33.3k
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
• 74.8k
Accepted

Making polygon from list of xy coordinates using Shapely

The shapely Polygon class constructor can receive a sequence of coordinate tuples, which you can create using the zip function. p = Polygon(list(zip(xv, yv))) or even simpler, you may as well create ...
• 3,581
Accepted

Rounding decimal numbers in PostGIS

Via Round ST_Distance you need to cast the values to a numeric: select name, round(ST_X(geom)::numeric, 2) as x_coordinate, round(ST_Y(geom)::numeric, 2) as y_coordinate from cities You could ...
• 10.9k