2

I'm trying to use CARTO for a school project and so I've just been trying to get the hang of the basics of using it and Postgis at the same time. I've read their docs about the difference between the_geom and the_geom_webmercator but I keep constantly tripping on it when writing queries.

Their docs:

the_geom: field where the geometries (points, lines, or polygons) are stored in the CARTO dataset. The geometries must be in the projection EPSG:4326 (WGS84 - Geodetic coordinate system for World)

the_geom_webmercator: this field is hidden in the dataset, and it stores the geometries in the projection EPSG:3857 (WGS84 Web Mercator (Auxiliary Sphere) - Projected coordinate system for World), this field is used to render the geometries on the map. This field is automatically updated when a geometry in the_geom field is added or updated.

Why does it seem like I find some query examples that use the_geom but others that use the_geom_webmercator? Why do I find queries that mix the two? Why do they have both of these to begin with? When using postgis functions like st_intersects, should I always call it on one or the other?

I've read up on projections and coordinate systems and I generally get all this. But for some reason, I am constantly confused when trying to write queries in the Carto context.

5
  • On the one hand, the_geom stores the geography of your dataset. If your dataset contains points, then longitude and latitude values will be shown. The units of these coordinates are logically degrees.
  • On the other, the_geom_webmercator is the projection on a plane (in fact, your screen) of the geographic coordinates (the_geom). The coordinates are in a cartesian matrix, then we are talking about X and Y instead of longitude and latitude. Its units are in meters. Ths geometry is used to display your data.

You can work with both of them, but having in mind the differences stated above. If you want to create buffers or calculate distances, you could use the first and convert the results into Webmercator (casting or using ST_Transform). But I highly recommend that if you want accurateness, look for the best projection that fits your geography then transform the results into Webmercator.

| improve this answer | |

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.