dmartzol / dxfmaps

Generating maps from shapefiles into DXF format

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dxfmaps

Python module to generate vector maps from ESRI Shapefiles with the purpose of cutting custom maps in CNC controlled machines(e.g. Laser cutters or CNC milling machines).

Example

Features

  • Convenient SVG and DXF formats to import into CNC software for processing and cut.
  • Specify the desired width or height of the final SVG/DXF.
  • Include label for each country in separate layers of the DXF file.
  • Generate a vector map of all countries in a continent by just specifying the name of the continent.
  • Reducing the number of points in the data by simplifying polygons.
  • Implement greatest rectangle(in area) contained in a polygon
  • Generate a map of all the provinces/states in a country specifying the name of the country.

Installation

Install with:

git clone https://github.com/dmartzol/dxfmaps.git
cd dxfmaps
pip install -e .

Requirements

  • pyshp - Library for reading ESRI Shapefiles
  • Shapely - Manipulation and analysis of geometric objects
  • ezdxf - Creation and manipulation of DXF drawings

Usage and examples

from dxfmaps.map import Map
from dxfmaps.utils import WORLD_COUNTRIES
from dxfmaps.projections import *


def main():
    map = Map(WORLD_COUNTRIES, continent="europe")
    map.filter_by_area(area_limit=1.0)
    map.simplify(tolerance=.015)
    map.project(MERCATOR)
    map.translate_to_center()
    map.scale_to_width(1000)
    map.add_labels()
    map.to_png(filename='europe.png', stroke_width=2.0)
    map.to_svg()
    map.to_dxf()


if __name__ == "__main__":
    main()

TO DO

  • Implement Azimuthal and Winkel Triple and Mercator projections.
  • Implement smaller buffered map for back support.
  • Add country names.
  • Implement PNG support.
  • Add credits(Natural Earth logo, etc).
  • Comment code.
  • Add support for other data sources(.gov)
  • Calculate adequate tolerance for method 'simplify'.
  • Move unused functions to deprecated
  • Implement imperial units?

License

This project is licensed under the MIT License

Acknowledgments

  • Built using data from Natural Earth, using the maps for countries and states/provinces.

About

Generating maps from shapefiles into DXF format

License:MIT License


Languages

Language:Python 84.1%Language:HTML 15.9%