Examples of country or regions polygons

Created on 5 August 2025, 12 days ago

Thanks for this great module!

Do you have any pointers on how to obtain countries or regions polygons?

Would you recommend importing polygons from an external source into a geofield? Or use geocoder to populate geofield with polygons?

Is the code of the demo available so I can see how it was implemented?

Kind regards,
Boris

💬 Support request
Status

Active

Version

1.0

Component

Documentation

Created by

🇳🇱Netherlands batigolix Utrecht

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @batigolix
  • 🇮🇹Italy itamair

    Hi @batigolix

    The web should provide plenty of Open Geojson datasets.
    You just need to search and look for them …
    Just googling you could find this on top of the results list, for instance:
    https://open-innovations.org/data/geojson.html

    But there should be everywhere, somewhere, etc.

    The Geojson format is something that is natively supported by the Drupal Geofield (and Leaflet) widgets,
    so for instance you could simply copy an paste the source GeoJson content into each Geofield/Leaflet Widget text area (refer to the Drupal_Leaflet_Widget_screenshot.jpg attached file) and save the entity and it will then be stored in your Drupal app (as WKT in the db).

    You could eventually try this also taking advantage of the great https://geojson.io platform: generate your sample GeoJson content there and then paste it into the Geofield/Leaflet Widget text area …

    But you should also consider that GeoJson is one of the latest and most open Geo Format out there.
    Many Geo Data sources should still be provided in some older and more closed formats, but still much used in the world geo community (such the shape file, not natively supported as input by Drupal Geofield/Leaflet).
    For this there are also (more or less open) converting tools into GeoJson (or tutorials) such these ones:
    - https://mygeodata.cloud/converter/shp-to-geojson
    - https://gis.stackexchange.com/questions/479481/converting-shapefiles-int...

    Last but not least you might consider the Drupal Leaflet Widget itself for generating your GeoJson / Geofield data, taking advantage of its drawing tools (still refer to the Drupal_Leaflet_Widget_screenshot.jpg attached file).

    For what concerns the code of the demo … well, there is no specific / custom code, but simply the Leaflet Choropleth module code itself and it specific settings of the "leaflet_choropleth_map” @ViewsStyle implemented on that US States dataset.
    And as mentioned in the header of the Leaflet Choropleth Map demo, the content is coming the corresponding Leaflet Geojson example from here:
    https://leafletjs.com/examples/choropleth/ , that is using this GeoJson data: https://leafletjs.com/examples/choropleth/us-states.js
    You can notice that I also now added in the same view header this link to the GeoJson View Api endpoint of the Geodata used in the Drupal demo itself:
    “Access this data via internal GeoJson API Endpoint”

    My suggestions on how to import Geo Polygons/Geometries data in Drupal are the following:
    - convert your source data in Geojson format (if not already in that format);
    - yes the Geocoder module can transform a GeoJson file into a Geofield content, but for Choropleth mapping, rather than a unique Entity (& Geofield) storing all your geometries (via GeoJson) you would need to split and generate one Entity / Geofield for each polygon. Thus you need to split the origin GeoJson source into multiple ones … and at that point it would be easier to just copy / paste those into Entity Geofield/Leaflet Widget text areas manually
    - in case of a unique GeoJson source file (like the one from the Leaflet Geojson demo) and your need to create a Drupal Entity (with Geofield) for each feature / polygon in the GeoJson source ((for Chropleth representation) best would be to rely on the following approaches:
    - use the Feeds module ( https://www.drupal.org/project/feeds ) with the Feeds Extensible Parsers ( https://www.drupal.org/project/feeds_ex ) and eventually the Feeds Tamper ( https://www.drupal.org/project/feeds_tamper )
    - use the Migrate Module ( https://www.drupal.org/project/migrate ) with Migrate Plus ( https://www.drupal.org/project/migrate_plus )

    Both (alternative) imports with Feeds and Migrate modules are supported by the Geofield stack, and I let you discover and go more through & consolidate proper workflows that would fit your needs, as it is very common in the Drupal self learning process.

    Hope (and confident) all this helps.

    My regards.

Production build 0.71.5 2024