项目作者: thinkingmachines

项目描述 :
地理空间数据的自动化功能工程
高级语言: Python
项目地址: git://github.com/thinkingmachines/geomancer.git
创建时间: 2019-02-25T09:39:01Z
项目社区:https://github.com/thinkingmachines/geomancer

开源协议:MIT License

下载


" class="reference-link">Geomancer Logo

















Geomancer is a geospatial feature engineering library. It leverages geospatial
data such as OpenStreetMap (OSM) alongside a
data warehouse like BigQuery. You can use this to create, share, and iterate
geospatial features for your downstream tasks (analysis, modelling,
visualization, etc.).



Features

Geomancer can perform geospatial feature engineering for all types of vector data
(i.e. points, lines, polygons).

  • Feature primitives for geospatial feature engineering
  • Ability to switch out data warehouses (BigQuery, SQLite, PostgreSQL (In Progress))
  • Compile and share your features using our SpellBook

Setup and Installation

Installing the library

Geomancer can be installed using pip.

  1. $ pip install geomancer

This will install all dependencies for every data-warehouse we support. If
you wish to do this only for a specific warehouse, then you can add an
identifier:

  1. $ pip install geomancer[bq] # For BigQuery
  2. $ pip install geomancer[sqlite] # For SQLite
  3. $ pip install geomancer[psql] # For PostgreSQL

Alternatively, you can also clone the repository then run install.

  1. $ git clone https://github.com/thinkingmachines/geomancer.git
  2. $ cd geomancer
  3. $ python setup.py install

Setting up your data warehouse

Geomancer is powered by a geospatial data warehouse: we highly-recommend using
BigQuery as your data warehouse and
Geofabrik’s OSM catalog as your
source of Points and Lines of interest.

Geomancer architecture

You can see the set-up instructions in this link

Basic Usage

All of the feature engineering functions in Geomancer are called “spells”. For
example, you want to get the distance to the nearest supermarket for each
point.

  1. from geomancer.spells import DistanceToNearest
  2. # Load your dataset in a pandas dataframe
  3. # df = load_dataset()
  4. dist_spell = DistanceToNearest(
  5. "supermarket",
  6. source_table="ph_osm.gis_osm_pois_free_1",
  7. feature_name="dist_supermarket",
  8. dburl="bigquery://project-name",
  9. ).cast(df)

You can specify the type of filter using the format {column}:{filter}. By
default, the column value is fclass. For example, if you wish to look for
roads on a bridge, then pass bridge:T:

  1. from geomancer.spells import DistanceToNearest
  2. # Load the dataset in a pandas dataframe
  3. # df = load_dataset()
  4. dist_spell = DistanceToNearest(
  5. "bridge:T",
  6. source_table="ph_osm.gis_osm_roads_free_1",
  7. feature_name="dist_road_bridges",
  8. dburl="bigquery://project-name",
  9. ).cast(df)

Compose multiple spells into a “spell book” which you can export as a JSON file.

  1. from geomancer.spells import DistanceToNearest
  2. from geomancer.spellbook import SpellBook
  3. spellbook = SpellBook([
  4. DistanceToNearest(
  5. "supermarket",
  6. source_table="ph_osm.gis_osm_pois_free_1",
  7. feature_name="dist_supermarket",
  8. dburl="bigquery://project-name",
  9. ),
  10. DistanceToNearest(
  11. "embassy",
  12. source_table="ph_osm.gis_osm_pois_free_1",
  13. feature_name="dist_embassy",
  14. dburl="bigquery://project-name",
  15. ),
  16. ])
  17. spellbook.to_json("dist_supermarket_and_embassy.json")

You can share the generated file so other people can re-use your feature extractions
with their own datasets.

  1. from geomancer.spellbook import SpellBook
  2. # Load the dataset in a pandas dataframe
  3. # df = load_dataset()
  4. spellbook = SpellBook.read_json("dist_supermarket_and_embassy.json")
  5. dist_supermarket_and_embassy = spellbook.cast(df)

Contributing

This project is open for contributors! Contibutions can come in the form of
feature requests, bug fixes, documentation, tutorials and the like! We highly
recommend to file an Issue first before submitting a Pull
Request
.

Simply fork this repository and make a Pull Request! We’d definitely appreciate:

  • Implementation of new features
  • Bug Reports
  • Documentation
  • Testing

Also, we have a
CONTRIBUTING
and a CODE_OF_CONDUCT,
so please check that one out!

License

MIT License © 2019, Thinking Machines Data Science