1

I'm using QGIS for editing an PostGIS database. This database gives me only lines (streets of a city). But, I have to edit the PostGIS because some streets have changed. So, I put a base map (new layer) as a reference (Google Maps for example), but I have problems with CRS of them.

The PostGIS database have EPSG 22181 and when I try to convert Google Maps layer to this EPSG I don't see any changes... I cannot see the 2 layers on the same map.

What am I doing wrong?


Nate thans for your time!. Here I post the images. This is the SRC of my Postgis database enter image description here

Here it's whats my QGIs database manager gives me related to Postgis database enter image description here

And here you have project SRC enter image description here

Here the GoogleMaps SRC enter image description here

ANd finally here it's whats my problem, I can't see both maps on the same screen. enter image description here

  • Which coordinates system you want to use for your project? – Shiko Nov 4 '16 at 16:37
  • 1
    If you use the OpenLayers Plugin for the basemap, you have to stick to EPSG:3857 as project CRS. Other layers can have different CRS. If the Postgis layer does not align, please add the extent of that layer, as reported by rightclick on the layer -> Properties -> Metadata -> Properties section, and where on Earth the data should be. – AndreJ Nov 4 '16 at 16:45
  • Ok, I want to work with EPSG 22181 (the Postgis has this system). So, I want to change GoogleMaps basemap to this CRS. I'am using QuickMapServices to put the basemap – Pablo Garín Nov 4 '16 at 16:56
  • The postgis extent is: +proj=tmerc +lat_0=-90 +lon_0=-72 +k=1 +x_0=1500000 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs – Pablo Garín Nov 4 '16 at 17:10
  • 1
    @PabloGarín That's not the extent, that's just the CRS definition string – underdark Nov 4 '16 at 18:27
1

Under Project --> Project Properties --> CRS, make sure that "Enable 'on the fly' CRS transformation" is checked. If this doesn't do the trick, look at the layer properties, and make sure they are set to match the data source (not how you want them to display). This should be EPSG 22181 for your database, and EPSG 3857 for the Google Maps basemap.

Assuming you are working with a limited amount of vector data in your database, you will likely want to set your project CRS to 3857. The street lines will be projected from 22181 to 3857 on the fly to show on your screen, while the Google Maps would stay in 3857. If you find the street lines are taking awhile to render, you could try setting the project CRS to 22181, in which case the Google Maps basemap would be converted from 3857 to 22181. I've generally found that on-the-fly projection of the Google Maps basemap can be more problematic.

I have also seen some issues with alignment, particularly with Google Maps, when you try to zoom in past a certain zoom level.

EDIT after screenshots: The coordinates on your screenshot do not make sense for EPSG 22181 projection. It looks like both x and y are negative, and the scale is 1:36 which would put the real-life scale of your map at only a few hundred meters. I expect your roads are much longer than that. I think it is likely that your data was not created in 22181, but some other projection. Try going to the Database --> DB Manager menu. Expand PostGIS and keep expanding to your line table. On the right, look for a "Spatial ref" entry for the table. The screenshot below shows where to look for a table I've been building in EPSG 4326. Do yours say 22181? If so, I think it possible that your roads were originally recorded in something like 4326 and were inadvertantly assigned to 22181. If so, it may require something like the PostGIS UpdateGeometrySRID in a SQL query, but you would need to figure out what it should have been first.

enter image description here

EDIT 2: It appears that your coordinates were actually in EPSG 4326, despite your table being set for 22181. There are two ways to fix this. The first is to set the table to 4326 without changing any of the coordinates themselves. This would be done with something like UpdateGeometrySRID in SQL (QGIS --> DB Manager --> Database --> SQL Window or using pgAdmin):

SELECT UpdateGeometrySRID('line', 'the_geom', 4326);

Your other option is to convert the geometries to 22181 coordinates using ST_Transform. See this post for instructions if you choose this route.

As an aside, you may consider renaming the 'line' table to 'road' or 'street', to avoid confusion with the geometries themselves.

  • Sorry, I couldn't make it to work.. I put project SRC to 22181 (on the fly) al my postgis database shows ok, but I can't make to overlap the 2 maps (Google and postgis). I made to "zoom to layer" on Google Maps and Postgis Database and I see them but in separate maps, not in one map. – Pablo Garín Nov 7 '16 at 13:22
  • Can you post screenshots? – Nate Wanner Nov 7 '16 at 14:02
  • imgur.com/a/3Brje – Pablo Garín Nov 7 '16 at 16:48
  • @PabloGarín I just edited my answer above with some more ideas. If you get a chance to add the last two images directly to the question, that will help document your question for future visitors. I could not be certain what layers the first two screenshots showed, though I presume it was Google Maps first and the database second. – Nate Wanner Nov 8 '16 at 0:16
  • @PabloGarín In your layers panel (bottom left, panel de capas), right click on 'lines' and change the CRS to 4326. Then right-click and zoom-to-layer. Does that look better? – Nate Wanner Nov 8 '16 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.