Skip to main content
38 votes
Accepted

Re-project raster in python using GDAL?

So, thanks to @Luke I used the simple line: gdal.Warp(output_raster,input_raster,dstSRS='EPSG:4326') and it works, this was exactly what I was looking for, simple code with few line to execute simple ...
user88484's user avatar
  • 1,839
32 votes

Transforming Shapely Polygon and MultiPolygon objects

If you're using pyproj2, it's much easier to use a Transformer. Here's an example: import pyproj from shapely.ops import transform project = pyproj.Transformer.from_proj( pyproj.Proj(init='epsg:...
Nick ODell's user avatar
32 votes

Unable to snap vertices and segment in QGIS 3.0

In QGIS 3.0, the snapping settings are accessed through the snapping toolbar. This is a change from previous versions. In QGIS 2.x they were accessed through Options menu > Snapping Options... ...
csk's user avatar
  • 25k
30 votes
Accepted

Changing shapefiles from geographic (WGS84) to projected (EPSG:2263) coordinate system using QGIS

This answer has four sections: What you should do to solve the problem and what you should avoid An example to better illustrate why assigning CRS and reprojecting are not the same An analogy that ...
Babel's user avatar
  • 73.8k
29 votes
Accepted

Extracting EPSG from a raster using gdal bindings in Python

I found the following workaround. I am unsure if it is the most efficient, but it does work for me. from osgeo import gdal, osr path = r"C:\temp\test2.tif" d = gdal.Open(path) proj = osr....
Lennert De Feyter's user avatar
25 votes
Accepted

Understanding reprojection?

Reprojection in GIS consists in changing the coordinates values of a dataset from one coordinate system to another coordinate system. Let's take a one dimensionnal case as an exampple. Imagine that ...
radouxju's user avatar
  • 49.8k
24 votes
Accepted

Calculating area of lat/lon polygons without transformation using GeoPandas

Overview Since version 0.7.0 geopandas has embedded the pyproj library as the crs object. pyproj, since version 2.3.0, has the ability to calculate the area of arbitrary polygons on a sphere. (see ...
Shawn's user avatar
  • 1,867
23 votes

How can EPSG:3857 be in meters?

It is a projection of a spheroid on a flat surface. Every projection has strengths and weaknesses and will preserve some elements of direction, distance or area better or worse than others (which is ...
MappaGnosis's user avatar
  • 33.9k
21 votes

EPSG 3857 or 4326 for Web Mapping

It's confusing when an API says it uses SRID 3857 but gives a location using SRID 4326 Quick way of telling what SRID your lat/lon is in: Look at how big the number & the precision EPSG:4326 is ...
user179876's user avatar
20 votes

Converting projected coordinates to lat/lon using Python

When using pyproj, note the differences from various releases in how it is used to transform data. Here are a few examples using new/old capabilities based on the question: Using pyproj >= 2.2.0 ...
Mike T's user avatar
  • 42.2k
20 votes

Understanding Coordinate Reference System of QGIS Project and Layer

Short answer: there is project CRS and layer CRS: You can more or less freely choose any project CRS, QGIS handles the rest automatically. You can't "set" another CRS for your layer (your ...
Babel's user avatar
  • 73.8k
20 votes
Accepted

Showing the bounding box for every coordinate system in QGIS

Yes, QGIS holds this information in an SQLite table. Go the menu layer / data source manager and select Browser then go to where QGIS is installed (like C:\Program Files\QGIS 3.16\) and dig down to ...
JGH's user avatar
  • 42.5k
19 votes
Accepted

Auto-select suitable UTM Zone based on Grid Intersection

There's the utm package, a bidirectional UTM-WGS84 converter for python. It's able to convert a (latitude, longitude) tuple into an UTM coordinate: import utm utm.from_latlon(51.2, 7.5) >>> (...
Antonio Falciano's user avatar
19 votes

What does "¢" mean in a coordinate?

Your viewer, or the website, has some problem with the fonts. Perhaps your browser does not get access to the defined fonts. Works for me, though, and this is how it should look: Coordinates are ...
user30184's user avatar
  • 67.9k
18 votes
Accepted

EPSG code for UTM zone

The UTM zones and their respective EPSG codes cover the whole area of their respecive zone from the equator to 84N / 80S. These areas are subdivided by the letters from South to North, and these again ...
user6072577's user avatar
  • 1,582
18 votes

Opening PRJ file in text editor?

Right click and open with a text editor like notepad (or Notepad ++). It's not a GIS layer, just some projection metadata on your layer. A shapefile is made of severall files with some mandatory. The ...
gisnside's user avatar
  • 7,868
17 votes
Accepted

ST_DWithin Calc Meters - transform or cast?

As described, the answer is "neither", for the following reasons: Take a spatial table in 4326. Build a spatial index on it. The spatial index is a planar index, consisting of the 2D bounds of the ...
Paul Ramsey's user avatar
  • 19.9k
17 votes

Create spatial polygon grid from spatial points in R

here is a solution using sf and sf::st_make_grid: library(raster) library(sf) e <- as(raster::extent(-125, -65, 25, 49), "SpatialPolygons") %>% st_as_sf() grd_lrg <- st_make_grid(e, ...
sebdalgarno's user avatar
  • 1,733
17 votes

Why do zones differ for WGS84 UTM in Google Earth Pro vs. in QGIS 3.4?

There are 60 UTM Zones, each 6 degrees wide (about 700km at the equator), and stretching from 84 degrees North to 80 degrees South (the poles are reference with the Universal Polar Stereographic grid ...
Christiaan Adams's user avatar
17 votes
Accepted

Calculate percentage overlap of 2 sets of polygons in R

You're almost there! You can calculate the area of your new intersecting shapes, and then merge this back into your nc object: # Calculate area and tidy up intersect_pct <- st_intersection(nc, ...
Sandy AB's user avatar
  • 550
17 votes
Accepted

What kind of coordinates are 38,40.1365N, 75,4.23933W?

Mobile devices use WGS84 coordinates, and the coordinates might be displayed in different formats. One of them is DDM format. A comma for separating degree and minute, a dot for decimal. Your ...
Kadir Şahbaz's user avatar
16 votes
Accepted

Creating custom Coordinate System in PostGIS

It's easy here Look it up on http://www.spatialreference.org Find it SR-ORG:7069 NAD_1983_HARN_StatePlane_Michigan_South_FIPS_2113_IntlFeet Click PostGIS spatial_ref_sys INSERT statement Run that ...
Evan Carroll's user avatar
  • 7,111
16 votes

Auto-select suitable UTM Zone based on Grid Intersection

Alright, the answer from Antonio above is definitely right and pointed me in the correct direction. Here is the complete code: # convert_wgs_to_utm function, see https://stackoverflow.com/a/40140326/...
Alex's user avatar
  • 714
16 votes
Accepted

Adding Properties to a feature in Google Earth Engine

Yes, you can use the feature.set()option which Feature Overview covers with these examples: // Make a feature and set some properties. var feature = ee.Feature(ee.Geometry.Point([-122.22599, 37.17605]...
whyzar's user avatar
  • 12.1k
16 votes
Accepted

Reprojecting layer using PyQGIS

You can use processing algorithm native:reprojectlayer. Example: lyr = iface.activeLayer() parameter = { 'INPUT': lyr, 'TARGET_CRS': 'EPSG:4326', 'OUTPUT': 'memory:Reprojected' } result = ...
Fran Raga's user avatar
  • 7,878
15 votes

From shapefile to Python NetworkX?

I might have found a nice Python solution referring to the very shapefile in the question, so I am posting it for future reference. import networkx as nx import matplotlib.pyplot as plt G=nx....
FaCoffee's user avatar
  • 843
15 votes
Accepted

What does the default crs being EPSG:3857 in Leaflet mean?

Leaflet can be a bit confusing for hardcore GIS people, since a L.CRS does not represent an abstract CRS. Quoting from the Leaflet docs, it rather... [...] defines coordinate reference systems for ...
IvanSanchez's user avatar
  • 10.3k
15 votes
Accepted

Layer disappears when changing from CRS in degrees to CRS in meters in QGIS

Do not use "Set CRS" within layer properties. This does not reproject your data. You only define the CRS there. Means: you tell QGIS that the layer is in a different CRS than it actually is. ...
MrXsquared's user avatar
  • 35.2k
15 votes
Accepted

What is meant with EPSG:4326 projection

You've got a good grasp of it. EPSG 4326 (i.e. WGS 84) is not a projection. But if you don't associate a projection to this geographic coordinate system, and naively render the coordinates as x/y ...
alphabetasoup's user avatar
15 votes
Accepted

Projection transformation of a shapefile

What went wrong: If you transform, only the vertices are transformed, not the connecting line: this is always drawn as a straight line on the projected map canvas. So it's "path" will differ ...
Babel's user avatar
  • 73.8k

Only top scored, non community-wiki answers of a minimum length are eligible