Skip to main content

Library for generating Jvectormap based maps from shapefiles and geojson, Works on Python 3

Project description

shp2jvmapgen

Python library for generating jvectormap-based maps from shapefiles or GeoJSON, including the user's selected fields from the source file to become the id and name of the polygon in the jvectormap. This library runs on Python 3.

A shapefile, in simpler terms, is like a digital map that contains information about the shapes and locations of various features. Think of it as a digital filing cabinet, storing information about roads, buildings, rivers, and other features that make up the geography of a region. It’s not just a static image, but a dynamic collection of data that can be used to analyze and understand the world around us. Whether it's for city planning, environmental studies, or even video game design, the shapefile is a powerful tool that provides a way to represent and analyze real-world data in a spatial context.

GeoJSON is a geographic data interchange format based on JavaScript Object Notation (JSON). It is used to represent various types of geographic features such as points, lines, and polygons (referred to as "features"), and their properties. GeoJSON features are specified with a set of coordinates and optional properties, and can be easily integrated into web-based maps and GIS systems. GeoJSON is a widely used format for encoding and sharing spatial data on the web and is supported by many software libraries and tools for web mapping, data analysis, and spatial data processing.

jVectorMap is a library for creating interactive vector maps on a web page. It's like having a digital world map at your fingertips, where you can zoom in, zoom out, and even highlight different regions. But what makes jVectorMap different from a regular map is that it's designed to be used in web applications, meaning you can easily add it to your website or web-based project. With jVectorMap, you can display information in a way that's both visually appealing and interactive, allowing your users to explore the data and gain insights in a fun and engaging way. So, whether you're working on a data visualization project, creating a geography quiz, or just looking for an interactive way to display information, jVectorMap is a tool worth checking out.

jVectorMap relies on JavaScript to work and it only supports its own format for map data. This means that in order to use jVectorMap, you'll need to provide it with a map in jVectorMap format or convert an existing map into this format. And this is the python library to convert your shapefiles into jvectormaps.

First, import the library to your python console:

  from shp2jvmapgen import shp2jvmap as s2jvm

The library use JVMapgenerator class to make new object, then convert your source file to jvectormap while setting the width pixel to apply into your jvectormap

JVMapgenerator:

First, you need to inisiate the class.

  # default source file format is shapefile
  generator = s2jvm.JVMapGenerator()
  # for GeoJSON source file format
  generator = s2jvm.JVMapGenerator(sourceformat = "geojson")

Continue to shapefile exploration function. Use printFields() method to know the layer fields names. With this method you can
print all fields of your shapefile, then you can choose and use them as jvectormap polygon id and name attributes.

  # for shapefile source file format
  generator.printFields('path/to/file.shp')
  # for GeoJSON source file format
  generator.printFields('path/to/file.geojson')

Once you have selected your id and name, you have to call run() method. This function require 5 parameters: The input file path, the output file path, name and id as you've choosen and width pixel value that is an integer or float, like you can see below. This method will create the jvectormap file in the defined output file path.

  width_pixel = 800
  id_field = 'ID'
  name_field = 'Region_Name'
  input_file= 'path/to/input_file.shp'      # change the input file path to your file, if its a Geojason
  output_file = 'path/to/output_file.js'

  generator.run(input_file, output_file, id_field, name_field, width_pixel)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shp2jvmapgen-0.0.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

shp2jvmapgen-0.0.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file shp2jvmapgen-0.0.2.tar.gz.

File metadata

  • Download URL: shp2jvmapgen-0.0.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for shp2jvmapgen-0.0.2.tar.gz
Algorithm Hash digest
SHA256 7a76b989f7f388bfe093d21a97bf03d20fa5a4b22e809f7f6070fd7f3cd86dbf
MD5 3305e2afc862496aa389058358624dbb
BLAKE2b-256 4fcc576fdcec6c5699012714cd36593d8ae1e7a9a854d0224906c1fb327ffca1

See more details on using hashes here.

File details

Details for the file shp2jvmapgen-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: shp2jvmapgen-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for shp2jvmapgen-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 75fbd3d8cc3111e7b5168a1729ff11f7eec39be23a88478308a5babb30142d75
MD5 030e714af7aec6f44008d355126002c4
BLAKE2b-256 a4c4da997b6818671ac8c08833d0a6aeb8c84312b0c36605ea8c9166319804ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page