-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 47a0629
Showing
17 changed files
with
1,556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.DS_Store | ||
.idea/ | ||
.ipynb_checkpoints/ | ||
ENV/ | ||
*.egg-info/ | ||
*.pyc |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
shp2city is a software able to convert cartographic data, containing building information, from ESRI shapefile format to 3D CityGML model. | ||
It supports in input one or multiple ESRI shapefile that used to generate a cityGML file. | ||
In order to perform the conversion process, several parameters should be set by user. | ||
Specifically, the following are requested: | ||
(1) the name of output CityGML file | ||
(2) a spatial relationship parameter, chosen between: “intersects”, “within” or “contains” | ||
(3) paths of inputs files. | ||
|
||
The first parameter will be used in the final step in order to save the 3d model. | ||
The second parameter is a fundamental request in order to perform spatial join between multiple files. The choice of this parameter is restricted to three possibilities: i) intersects, ii) contains, iii) within | ||
As for the remaining parameter, it can be composed of paths to one or two shapefiles. | ||
In case there is only one input file, the spatial join step is skipped and the CityGML file will be processed from the single input file purge from null geometries. | ||
In presence of two files, the spatial join process can be performed according to the spatial relation specified as input parameter. | ||
|
||
##Installation of the command-line tool | ||
For unix os: | ||
$ pip install shp2city | ||
|
||
To see all the options possible: | ||
|
||
$ shp2city --help | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# shp2city: program to convert shapefile to cityGML | ||
# Copyright (C) 2018-2019 Francesca Fissore <[email protected]> | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
|
||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name='shp2city', | ||
version='0.1.0', | ||
description='Convert shapefile into cityGML', | ||
#url='https://github.com/pypa/sampleproject', # Optional | ||
author='Francesca Fissore', | ||
author_email='[email protected]', | ||
packages=find_packages(), | ||
install_requires=[ | ||
'geopandas', | ||
'lxml', | ||
'numpy', | ||
'pick', | ||
'rtree' | ||
], | ||
tests_require = [ | ||
'pytest', | ||
], | ||
entry_points={ | ||
'console_scripts': [ | ||
'shp2city=shp2city.main:main', | ||
], | ||
}, | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# shp2city: program to convert shapefile to cityGML | ||
# Copyright (C) 2018-2019 Francesca Fissore <[email protected]> | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
def buildings_inits(content, list_attributes, list_fields): | ||
inits = {} | ||
for attribute, field in zip(list_attributes, list_fields): | ||
if field != 'NA': | ||
inits[attribute] = str(content[field]) | ||
else: | ||
inits[attribute] = '' | ||
return inits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# shp2city: program to convert shapefile to cityGML | ||
# Copyright (C) 2018-2019 Francesca Fissore <[email protected]> | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import geopandas as gpd | ||
from shapely.geometry.polygon import Polygon | ||
from shapely.geometry.multipolygon import MultiPolygon | ||
|
||
def explode(indf): | ||
#indf = gpd.GeoDataFrame.from_file(indata) | ||
outdf = gpd.GeoDataFrame(columns=indf.columns) | ||
|
||
for idx, row in indf.iterrows(): | ||
#print row.geometry.type | ||
if row.geometry.type == 'Polygon': | ||
outdf = outdf.append(row,ignore_index=True) | ||
if row.geometry.type == 'MultiPolygon': | ||
multdf = gpd.GeoDataFrame(columns=indf.columns) | ||
recs = len(row.geometry) | ||
multdf = multdf.append([row]*recs,ignore_index=True) | ||
for geom in range(recs): | ||
multdf.loc[geom,'geometry'] = row.geometry[geom] | ||
outdf = outdf.append(multdf,ignore_index=True) | ||
|
||
return outdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from writer import write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# shp2city: program to convert shapefile to cityGML | ||
# Copyright (C) 2018-2019 Francesca Fissore <[email protected]> | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from lxml import etree | ||
|
||
|
||
namespaces = { | ||
None: "http://www.opengis.net/citygml/2.0", | ||
# "app": "http://www.opengis.net/citygml/appearance/2.0", | ||
# "bldg": "http://www.opengis.net/citygml/building/2.0", | ||
# "dem": "http://www.opengis.net/citygml/relief/2.0", | ||
# "frn": "http://www.opengis.net/citygml/cityfurniture/2.0", | ||
"gen": "http://www.opengis.net/citygml/generics/2.0", | ||
"gml": "http://www.opengis.net/gml", | ||
# "grp": "http://www.opengis.net/citygml/cityobjectgroup/2.0", | ||
# "luse": "http://www.opengis.net/citygml/landuse/2.0", | ||
# "pfx0": "http://www.citygml.org/citygml/profiles/base/2.0", | ||
# "veg": "http://www.opengis.net/citygml/vegetation/2.0", | ||
# "tex": "http://www.opengis.net/citygml/texturedsurface/2.0", | ||
# "tran": "http://www.opengis.net/citygml/transportation/2.0", | ||
# "wtr": "http://www.opengis.net/citygml/waterbody/2.0", | ||
# "xAL": "urn:oasis:names:tc:ciq:xsdschema:xAL:2.0", | ||
# "xlink": "http://www.w3.org/1999/xlink", | ||
# "xsi": "http://www.w3.org/2001/XMLSchema-instance", | ||
# "sch": "http://www.ascc.net/xml/schematron", | ||
# "smil20": "http://www.w3.org/2001/SMIL20/", | ||
# "smil20lang": "http://www.w3.org/2001/SMIL20/Language", | ||
} | ||
|
||
|
||
# def root(parent, no_namespaces=False): | ||
# nsmap = None if no_namespaces else namespaces | ||
# return parent.element("CityModel", nsmap=nsmap) | ||
|
||
def root(no_namespaces=False): | ||
nsmap = None if no_namespaces else namespaces | ||
return etree.Element("CityModel", nsmap=nsmap) | ||
|
||
def root2(xf, no_namespaces=False): | ||
nsmap = None if no_namespaces else namespaces | ||
return xf.element("CityModel", nsmap=nsmap) | ||
|
||
def element(element_name, parent=None, attributes=None, **kwargs): | ||
if attributes is None: | ||
attributes = kwargs | ||
else: | ||
attributes.update(kwargs) | ||
attributes = {qualify_name(k): v for k, v in attributes.items()} | ||
|
||
if parent is None: | ||
return etree.Element(qualify_name(element_name, always=True), **attributes) | ||
else: | ||
return etree.SubElement(parent, qualify_name(element_name, always=True), **attributes) | ||
|
||
def qualify_name(name, always=False): | ||
idx = name.find(':') | ||
if idx < 0: | ||
ns = None | ||
else: | ||
ns = name[:idx] | ||
name = name[idx+1:] | ||
|
||
if ns is None and always == False: | ||
return name | ||
else: | ||
urn = namespaces[ns] | ||
return '{%s}%s' % (urn, name) | ||
|
||
|
||
def identifier_format(identifier): | ||
if isinstance(identifier,unicode): | ||
pass | ||
else: | ||
pass#identifier = unicode(hex(identifier)) | ||
identifier= str(identifier) | ||
if identifier.startswith('RLB'): | ||
pass | ||
else: | ||
identifier = unicode('RLB-'+ str(identifier)) | ||
|
||
return identifier |
Oops, something went wrong.