0

I have a map in Leaflet:

  <TileLayer
    attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>'
    url="https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png"
  />
  {options.countryPolygon && <Polygon positions={options.countryPolygon} />}

I want to draw a Polygon of a specific country border. But every GeoJSON file I found does not contain precise boundaries so it does not cover the original layer well. Is there a way to extract the original border from this layer and highlight it?

I added illustration of problem I have met.

Drawn border is not exactly the same like this one from a layer

6
  • 1
    Welcome to GIS SE. As a new user, please take the Tour. International boundaries are subject to many potential complications, including capture scale, coordinate reference datum transformation, and political views. Tracking down the vector basis for the original image is likely to be more useful than trying to fit random data sources or digitizing from the source raster.
    – Vince
    Jul 11, 2023 at 19:47
  • @Vince Thanks Vince. I thought like this after checking 2-3 publicly available geojsons. But I can't find a way to track down the border vector basis of the original image/layer from this link (https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png). Is there some kind of tool that allows me to extract it from there (coordinates, of e.g. Albania but also other countries)? Or to map it somehow? Any suggestions or instructions are really welcome.
    – Seba
    Jul 11, 2023 at 19:52
  • The layer you referring to is tiled raster layer. There are no tools available to extract vector border from this layer.
    – TomazicM
    Jul 11, 2023 at 20:13
  • 1
    Does this answer your question? Higher resolution of country borders
    – TomazicM
    Jul 11, 2023 at 20:25
  • You can get pretty accurate country borders here: osm-boundaries.com/Map
    – TomazicM
    Jul 11, 2023 at 20:28

1 Answer 1

1

There are two problems you're facing here:

  • Trying to get detailed data from GeoJSON
  • There might be a projection error in the GeoJSON you're using

It looks (to me) like the GeoJSON you're using is very low detail and shifted to the right from the map baselayer, (looks like Google Maps) you're using. You need to check that the projection/SRID for both layers is the same. The default for webmaps is usually WGS84 or SRID:4326 but who knows what the SRID for your country was stored in.

If you want this to be precise then you're probably better off downloading a shapefile that provides an authoritative definition of the legal boundaries and use that instead of some GeoJSON you found while hitting F12 in Chrome. There are plenty. You can either convert them into GeoJSON yourself using QGIS or some other tool. You're probably also better off pulling a WFS layer off some GeoServer that has the exact definition that is scaled to the right map zoom level for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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