I am using the GADM database. Is there any way to determine landlocked polygons in QGIS and create a dummy variable for it ( 1==landlocked ; 0==not landlocked) ?

  • You'll need to use pyqgis. If your GADM is one layer, you need to first calculate the perimeter of every feature (this can be done with the field calculator), and then calculate the sum of intersection lengths with all other features in the layer. If the perimeter is equal to the sum of intersection lengths, the polygon is landlocked – the_darkside Jun 20 '17 at 4:07

you might be able to do this using the contains, within or relate geometry functions in QGIS. I think these are a fairly new additions.

I've not tried this with GADM or Natural Earth data, but you should be able to do this with QGIS expressions without having to resort to python code.

  • keep your country polygons in layer one ("country")
  • use dissolve to merge adjacent country polygons into layer two ("continent")
  • probably, also convert the dissolved 'continent' layer from single part to multipart

if the value of

  • contains(continent_geometry, country_geometry) is True OR
  • within(country_geometry, continent_geometry) is True

or using relate (I'm not so sure about these..!)

  • relate(country_geometry, continent_geometry) = "2FF1FF212" OR
  • relate(continent_geometry, country_geometry) = "212F11FF2"

...then the country geometry falls completely inside the outline of the continent, so it is landlocked.

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.