Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoSentinel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoSentinel
Commits
e81554ef
Commit
e81554ef
authored
Jul 31, 2018
by
Mario Chirinos Colunga
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
c509c925
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
myshape.dbf
geosentinel/myshape.dbf
+0
-0
rasterWkt.py
geosentinel/rasterWkt.py
+58
-0
No files found.
geosentinel/myshape.dbf
deleted
100644 → 0
View file @
c509c925
File deleted
geosentinel/rasterWkt.py
0 → 100644
View file @
e81554ef
#!/usr/bin/python
# -*- coding: utf-8 -*-
#"POLYGON((-89.65513229370117 21.048938357786966,-89.62852478027342 21.047816903874505,-89.6261215209961 21.03339745836918,-89.6465492248535 21.022822311328852,-89.65873718261717 21.039325621609095,-89.65513229370117 21.048938357786966))"
import
osgeo.ogr
as
ogr
import
osgeo.osr
as
osr
import
numpy
as
np
import
gdal
import
sys
#-------------------------------------------------------------------------------
def
createLayer
(
wkt
,
layerName
=
"wkt"
):
# create the spatial reference, WGS84
srs
=
osr
.
SpatialReference
()
srs
.
ImportFromEPSG
(
4326
)
layer
=
data_source
.
CreateLayer
(
layerName
,
srs
,
ogr
.
wkbPolygon
)
# Create the point from the Well Known Text
geometry
=
ogr
.
CreateGeometryFromWkt
(
wkt
)
# create the feature
feature
=
ogr
.
Feature
(
layer
.
GetLayerDefn
())
# Set the feature geometry using the point
feature
.
SetGeometry
(
geometry
)
# Create the feature in the layer (shapefile)
layer
.
CreateFeature
(
feature
)
# Dereference the feature
feature
=
None
return
layer
#-------------------------------------------------------------------------------
def
rasterWkt
(
wkt
,
inputfile
,
outputfile
):
'''
Draw WKT Polygon into a Image
'''
intput
=
gdal
.
Open
(
inputfile
)
rows
,
cols
,
geotransform
=
intput
.
RasterYSize
,
intput
.
RasterXSize
,
intput
.
GetGeoTransform
()
# Read the input bands as numpy arrays.
np_intput
=
intput
.
GetRasterBand
(
1
)
.
ReadAsArray
(
0
,
0
,
cols
,
rows
)
driverTiff
=
gdal
.
GetDriverByName
(
'GTiff'
)
output
=
driverTiff
.
Create
(
outputfile
,
cols
,
rows
,
1
,
gdal
.
GDT_Byte
)
output
.
GetRasterBand
(
1
)
.
SetNoDataValue
(
-
99
)
output
.
GetRasterBand
(
1
)
.
WriteArray
(
np_intput
)
output
.
GetRasterBand
(
1
)
.
FlushCache
()
output
.
SetGeoTransform
(
geotransform
)
wkt
=
b1
.
GetProjection
()
sr
=
osr
.
SpatialReference
()
sr
.
ImportFromWkt
(
wkt
)
output
.
SetProjection
(
sr
.
ExportToWkt
())
gdal
.
RasterizeLayer
(
output
,
[
1
],
createLayer
(
wkt
),
burn_values
=
[
0
])
output
=
None
def
main
(
argv
):
rasterWkt
(
argv
[
1
],
argv
[
2
],
argv
[
3
])
if
__name__
==
"__main__"
:
main
(
sys
.
argv
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment