SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
GEOGRAPHIC SCRIPTING IN GVSIG
HALFWAY BETWEEN USER AND DEVELOPER
Geoinformation Research Group,
Department of Geography
University of Potsdam
21-25 November 2016
Andrea Antonello
PART 6: FROM GEO INTO YOUR REPORT
REPORTING UTILITIES
From within gvSIG it is possible also to create charts and documents.
Since those functionalities are not completely integrated into the
scripting engine, some tricky looking imports are required most of the
time. This should not scare the user that want's to generate simple
reports in batch mode.
In the following examples we will see how to produce charts and
spreadsheets.libreoffice
OBJECTIVE
Let's assume we have to write a report about how min and max average
temperature changed between 1983 and 2005 in Germany.
We want to create:
a shapefile containing polygons connected to the temperatures
a chart showing the monthly averages of min and max
a spreadsheet with the cleaned up dataset (ex. remove header)
The maps have to be in CRS EPSG:32632.
The necessary data can be found on the page of Surface meteorology and
Solar Energy maintained by NASA: https://eosweb.larc.nasa.gov/sse/
SUMMARY OF THE STEPS
Before we start, let's create a script with the comments of what we are
going to implement:
# parse temperature data and extract
# a list of information: [lat, lon, tempJan, tempFeb,...]
# create the shapefile
## get polygon of Germany
## filter only the data contained in the
## polygon of Germany
## create polygons with attached temperatures
## and write the features into the shapefile
# create a chart of the average temperatures
# insert the parsed data into a spreadsheet
STEP 1: PARSE TEMPERATURE DATA
from gvsig import *
from gvsig.geom import *
def main(*args):
# parse temperature data and extract
# a dictionary {point: temperaturesList}
minPath = "/home/hydrologis/data/potsdam_data/22yr_T10MN"
dataFile = open(minPath, "r")
lines = dataFile.readlines()
dataFile.close()
data = {}
dataStarted = False
for line in lines:
if dataStarted or line.startswith("-90"):
dataStarted = True
lineSplit = line.split(" ")
lat = float(lineSplit[0])
lon = float(lineSplit[1])
pointLL = createPoint2D(lon, lat)
temperatures = []
for i in range(2, len(lineSplit)-1): # last is avg
temperatures.append(float(lineSplit[i]))
data[pointLL.convertToWKT()] = temperatures
print minData
STEP 1: PARSE TEMPERATURE DATA
def readData(path):
dataFile = open(path, "r")
lines = dataFile.readlines()
dataFile.close()
data = {}
dataStarted = False
for line in lines:
if dataStarted or line.startswith("-90"):
dataStarted = True
lineSplit = line.split(" ")
lat = float(lineSplit[0])
lon = float(lineSplit[1])
pointLL = createPoint2D(lon, lat)
temperatures = []
for i in range(2, len(lineSplit)-1): # last is avg
temperatures.append(float(lineSplit[i]))
data[pointLL.convertToWKT()] = temperatures
return data
def main(*args):
minPath = "/home/hydrologis/data/potsdam_data/22yr_T10MN"
maxPath = "/home/hydrologis/data/potsdam_data/22yr_T10MX"
minData = readData(minPath)
maxData = readData(maxPath)
To read also the max temperatures, let's do some code reuse:
STEP 2: GET GERMANY
# create the shapefile
## get polygon of Germany
countriesPath = "/home/hydrologis/data/potsdam_data/ne_10m_admin_0_countries.shp"
epsg = "EPSG:4326"
countriesLayer = loadLayer("Shape", shpFile=countriesPath, CRS=epsg)
features = countriesLayer.features("NAME='Germany'")
if features.getCount() != 1:
print "ERROR!"
return
for i in features:
germanyFeature = i.getCopy()
We can extract the polygon of Germany from a previous exercise:
It is very simple to get the points that are contained in the polygon:
## filter only the data contained in the
## polygon of Germany
allPointsWKT= minData.keys()
allPoints = map(lambda p: createGeometryFromWKT(p), allPointsWKT)
pointsInGermany = filter(lambda p: p.intersects(germanyFeature.GEOMETRY), allPoints)
print "Points in Germany are", len(pointsInGermany), "while all are", len(allPoints)
STEP 3: WRITE THE SHAPEFILE
## create polygons with attached temperatures
## and write the features into the shapefile
# create the transform between the original crs and the required
newEpsg = "EPSG:32632"
crs = getCRS(epsg)
newCrs = getCRS(newEpsg)
transform = crs.getCT(newCrs)
# create the new shapefile and set the editing mode
schema = createFeatureType()
schema.append("min", "DOUBLE", 8)
schema.append("max", "DOUBLE", 8)
schema.append("GEOMETRY", "GEOMETRY")
schema.get("GEOMETRY").setGeometryType(POLYGON, D2)
shape = createShape(schema, prefixname="minmaxtemperatures", CRS=newEpsg)
shape.edit()
First prepare the re-projection transformation and the output shapefile
STEP 3: WRITE THE SHAPEFILE
for point in pointsInGermany:
x = point.x
y = point.y
# points all represent the lower left corner
# create the polygon considering that
pts = [[x,y],[x,y+1],[x+1,y+1],[x+1,y],[x,y]]
polygon = createPolygon2D(pts)
# reproject the polygon
polygon.reProject(transform)
# use the point's WKT as key to get the temperature data
# from the dictionary
minAvg = sum(minData[point.convertToWKT()])/12.0
maxAvg = sum(maxData[point.convertToWKT()])/12.0
shape.append(min=minAvg, max=maxAvg, GEOMETRY=polygon)
shape.commit()
Then, in the main loop, reproject, average and write:
STEP 3: WRITE THE SHAPEFILE
# create an interval legend on the min values
intervalLegend = VectorialIntervalLegend(POLYGON)
intervalLegend.setStartColor(getColorFromRGB(0,0,255))
intervalLegend.setEndColor(getColorFromRGB(255,0,0))
intervalLegend.setIntervalType(1)
store = shape.getFeatureStore()
intervals = intervalLegend.calculateIntervals(store, "MIN", 5, POLYGON)
intervalLegend.setIntervals(intervals)
shape.setLegend(intervalLegend)
newview = currentProject().createView("Germany View")
newview.setProjection(getCRS(newEpsg))
newview.addLayer(shape)
newview.addLayer(countriesLayer)
newview.showWindow()
newview.centerView(shape.fullEnvelope)
Style and load the data. Also load the countries layer to check the result.
Since (as we already know) the countries layer will be messy outside the
32632 zone, also zoom to the area of Germany:
INTERMEDIATE CHECK
A this point the script, if run, should produce something like this
(countries are styled to only show the borders)
STEP 4: CHART THE DATA
Charts can be created through the use of the project.
Charting in not exactly integrated in the scripting engine, so it requires
for the user to import a whole pile of modules.
The following are the ones we will make use of in the example:
jfreechart
from org.jfree.chart import ChartFactory
from org.jfree.chart import ChartFrame
from org.jfree.data.xy import XYSeriesCollection
from org.jfree.data.xy import XYSeries
from org.jfree.chart.plot.PlotOrientation import *
STEP 4: CHART THE DATA
Let's pick the first point of the list of points inside Germany:
# create a chart of the average temperatures
chartPoint = pointsInGermany[0]
minTemperaturesList = minData[chartPoint.convertToWKT()]
maxTemperaturesList = maxData[chartPoint.convertToWKT()]
Then create the XY chart series, fill them with the temperature data per
month and add them to a series collection:
dataset = XYSeriesCollection()
seriesMin = XYSeries("min")
seriesMax = XYSeries("max")
for i in range(0, 12):
month = i + 1
seriesMin.add(month, minTemperaturesList[i])
seriesMax.add(month, maxTemperaturesList[i])
dataset.addSeries(seriesMin)
dataset.addSeries(seriesMax)
STEP 4: CHART THE DATA
Finally create the chart and display it in a windows:
chart = ChartFactory.createXYLineChart(
"Temperatures", # chart title
"Months", # x axis label
"Degrees", #y axis label
dataset,
VERTICAL, # orientation
True, # include legend
True, # tooltips?
False # URLs?
)
# show the chart in a window
frame = ChartFrame("Plot test", chart);
frame.pack();
frame.setVisible(True);
STEP 4: CHART THE DATA
The JFreechart window allows the user to zoom and save the current
chart as image.
STEP 5: SPREADSHEETS
To create an modify spreadsheets gvSIG makes use of the
project.
On its homepage a
. In there it is possible to find all the functions that are
used in the next example.
In the same way as for the charting part, also the spreadsheet part needs
some dedicated import statements:
jopendocument
section is dedicated to the programmer
documentation
from java.io import File
from org.jopendocument.model import OpenDocument
from org.jopendocument.dom.spreadsheet import SpreadSheet
from org.jopendocument.dom import OOUtils
STEP 5: SPREADSHEETS
It is simple to set values in the cells by using the column and row as one
would do with a matrix:
# write the header row in both sheets
header = ["lat", "lon", "jan", "feb", "mar", "apr", "may",
"jun", "jul", "aug", "sep", "oct", "nov", "dec"]
for i, value in enumerate(header):
minSheet.setValueAt(value, i, 0)
maxSheet.setValueAt(value, i, 0)
Once the imports are in place, it is possible to create a new spreadsheet
and add two sheets to it for the min and max table values:
# insert the parsed data into a spreadsheet
spreadsheetPath = "/home/hydrologis/data/potsdam_data/data_test.ods"
# create a spreadsheet
spreadSheet = SpreadSheet.create(2, 100, 70000)
minSheet = spreadSheet.getSheet(0)
minSheet.setName("MIN")
maxSheet = spreadSheet.getSheet(1)
maxSheet.setName("MAX")
STEP 5: SPREADSHEETS
Then we can loop the ranges of lat and lon in order to have an ordered list
of only the values inside Germany:
row = 0
for lat in range(-90, 89):
for lon in range(-180, 179):
p = createPoint2D(lon, lat)
if p in pointsInGermany:
row += 1
minSheet.setValueAt(lon, 1, row)
minSheet.setValueAt(lat, 0, row)
maxSheet.setValueAt(lon, 1, row)
maxSheet.setValueAt(lat, 0, row)
minTemperaturesList = minData[p.convertToWKT()]
maxTemperaturesList = maxData[p.convertToWKT()]
for i, t in enumerate(minTemperaturesList):
col = i + 2
minSheet.setValueAt(t, col, row)
maxSheet.setValueAt(maxTemperaturesList[i], col, row)
Finally, save and open the file:
outputFile = File(spreadsheetPath)
OOUtils.open(spreadSheet.saveAs(outputFile))
STEP 5: SPREADSHEETS
The resulting file should look like:
<license>
This work is released under Creative Commons Attribution Share Alike (CC-BY-SA).
</license>
<sources>
Much of the knowledge needed to create this training material has been produced
by the sparkling knights of the
<a href="http:www.osgeo.org">Osgeo</a>,
<a href="http://tsusiatsoftware.net/">JTS</a>,
<a href="http://www.jgrasstools.org">JGrasstools</a> and
<a href="http:www.gvsig.org">gvSIG</a> communities.
Their websites are filled up with learning material that can be use to grow
knowledge beyond the boundaries of this set of tutorials.
Another essential source has been the Wikipedia project.
</sources>
<acknowledgments>
Particular thanks go to those friends that directly or indirectly helped out in
the creation and review of this series of handbooks.
Thanks to Antonio Falciano for proofreading the course and Oscar Martinez for the
documentation about gvSIG scripting.
</acknowledgments>
<footer>
This tutorial is brought to you by <a href="http:www.hydrologis.com">HydroloGIS</a>.
<footer>

Más contenido relacionado

La actualidad más candente

A Survey Of R Graphics
A Survey Of R GraphicsA Survey Of R Graphics
A Survey Of R GraphicsDataspora
 
MS Sql Server: Doing Calculations With Functions
MS Sql Server: Doing Calculations With FunctionsMS Sql Server: Doing Calculations With Functions
MS Sql Server: Doing Calculations With FunctionsDataminingTools Inc
 
IGraph a tool to analyze your network
IGraph a tool to analyze your networkIGraph a tool to analyze your network
IGraph a tool to analyze your networkPushpendra Tiwari
 
Hive function-cheat-sheet
Hive function-cheat-sheetHive function-cheat-sheet
Hive function-cheat-sheetDr. Volkan OBAN
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsProf. Dr. K. Adisesha
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
The Algorithms of CSS @ CSSConf EU 2018
The Algorithms of CSS @ CSSConf EU 2018The Algorithms of CSS @ CSSConf EU 2018
The Algorithms of CSS @ CSSConf EU 2018Lara Schenck
 
New client side features - Microsoft Dynamics CRM 2016
New client side features - Microsoft Dynamics CRM 2016New client side features - Microsoft Dynamics CRM 2016
New client side features - Microsoft Dynamics CRM 2016Naveen Kumar
 
R Programming: Numeric Functions In R
R Programming: Numeric Functions In RR Programming: Numeric Functions In R
R Programming: Numeric Functions In RRsquared Academy
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 SolutionHazrat Bilal
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...
Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...
Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...Lara Schenck
 

La actualidad más candente (18)

A Survey Of R Graphics
A Survey Of R GraphicsA Survey Of R Graphics
A Survey Of R Graphics
 
MS Sql Server: Doing Calculations With Functions
MS Sql Server: Doing Calculations With FunctionsMS Sql Server: Doing Calculations With Functions
MS Sql Server: Doing Calculations With Functions
 
Cs practical file
Cs practical fileCs practical file
Cs practical file
 
IGraph a tool to analyze your network
IGraph a tool to analyze your networkIGraph a tool to analyze your network
IGraph a tool to analyze your network
 
Hive function-cheat-sheet
Hive function-cheat-sheetHive function-cheat-sheet
Hive function-cheat-sheet
 
R basic programs
R basic programsR basic programs
R basic programs
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Vb.net programs
Vb.net programsVb.net programs
Vb.net programs
 
week-3x
week-3xweek-3x
week-3x
 
The Algorithms of CSS @ CSSConf EU 2018
The Algorithms of CSS @ CSSConf EU 2018The Algorithms of CSS @ CSSConf EU 2018
The Algorithms of CSS @ CSSConf EU 2018
 
New client side features - Microsoft Dynamics CRM 2016
New client side features - Microsoft Dynamics CRM 2016New client side features - Microsoft Dynamics CRM 2016
New client side features - Microsoft Dynamics CRM 2016
 
R Programming: Numeric Functions In R
R Programming: Numeric Functions In RR Programming: Numeric Functions In R
R Programming: Numeric Functions In R
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...
Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...
Bridging the Design to Development Gap with CSS Algorithms (Algorithms of CSS...
 
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
 

Similar a PART 6: FROM GEO INTO YOUR REPORT

Opensource gis development - part 3
Opensource gis development - part 3Opensource gis development - part 3
Opensource gis development - part 3Andrea Antonello
 
Ge6161 lab manual
Ge6161 lab manualGe6161 lab manual
Ge6161 lab manualMani Kandan
 
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?Martin Loetzsch
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisUniversity of Illinois,Chicago
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisUniversity of Illinois,Chicago
 
Graphs made easy with SAS ODS Graphics Designer (PAPER)
Graphs made easy with SAS ODS Graphics Designer (PAPER)Graphs made easy with SAS ODS Graphics Designer (PAPER)
Graphs made easy with SAS ODS Graphics Designer (PAPER)Kevin Lee
 
Star Transformation, 12c Adaptive Bitmap Pruning and In-Memory option
Star Transformation, 12c Adaptive Bitmap Pruning and In-Memory optionStar Transformation, 12c Adaptive Bitmap Pruning and In-Memory option
Star Transformation, 12c Adaptive Bitmap Pruning and In-Memory optionFranck Pachot
 
Make sure to make a copy of the Google Doc for this lab into.pdf
Make sure to make a copy of the Google Doc for this lab into.pdfMake sure to make a copy of the Google Doc for this lab into.pdf
Make sure to make a copy of the Google Doc for this lab into.pdfadityastores21
 
Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10alish sha
 
TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)
TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)
TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)Laud Randy Amofah
 
Creating Shape Models from Complex CAD drawings
Creating Shape Models from Complex CAD drawingsCreating Shape Models from Complex CAD drawings
Creating Shape Models from Complex CAD drawingsRussell Crook
 
Dynamic Graph Plotting with WPF
Dynamic Graph Plotting with WPFDynamic Graph Plotting with WPF
Dynamic Graph Plotting with WPFIJERD Editor
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with MathematicaMiles Ford
 
Web Developer make the most out of your Database !
Web Developer make the most out of your Database !Web Developer make the most out of your Database !
Web Developer make the most out of your Database !Jean-Marc Desvaux
 
AI02_Python (cont.).pptx
AI02_Python (cont.).pptxAI02_Python (cont.).pptx
AI02_Python (cont.).pptxNguyễn Tiến
 

Similar a PART 6: FROM GEO INTO YOUR REPORT (20)

Opensource gis development - part 3
Opensource gis development - part 3Opensource gis development - part 3
Opensource gis development - part 3
 
Jfreechart tutorial
Jfreechart tutorialJfreechart tutorial
Jfreechart tutorial
 
Ex32018.pdf
Ex32018.pdfEx32018.pdf
Ex32018.pdf
 
Ge6161 lab manual
Ge6161 lab manualGe6161 lab manual
Ge6161 lab manual
 
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
Project A Data Modelling Best Practices Part II: How to Build a Data Warehouse?
 
Unit 2 part-2
Unit 2 part-2Unit 2 part-2
Unit 2 part-2
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
 
Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
 
C++
C++C++
C++
 
Graphs made easy with SAS ODS Graphics Designer (PAPER)
Graphs made easy with SAS ODS Graphics Designer (PAPER)Graphs made easy with SAS ODS Graphics Designer (PAPER)
Graphs made easy with SAS ODS Graphics Designer (PAPER)
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
Star Transformation, 12c Adaptive Bitmap Pruning and In-Memory option
Star Transformation, 12c Adaptive Bitmap Pruning and In-Memory optionStar Transformation, 12c Adaptive Bitmap Pruning and In-Memory option
Star Transformation, 12c Adaptive Bitmap Pruning and In-Memory option
 
Make sure to make a copy of the Google Doc for this lab into.pdf
Make sure to make a copy of the Google Doc for this lab into.pdfMake sure to make a copy of the Google Doc for this lab into.pdf
Make sure to make a copy of the Google Doc for this lab into.pdf
 
Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10Bti1022 lab sheet 9 10
Bti1022 lab sheet 9 10
 
TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)
TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)
TIME SERIES ANALYSIS USING ARIMA MODEL FOR FORECASTING IN R (PRACTICAL)
 
Creating Shape Models from Complex CAD drawings
Creating Shape Models from Complex CAD drawingsCreating Shape Models from Complex CAD drawings
Creating Shape Models from Complex CAD drawings
 
Dynamic Graph Plotting with WPF
Dynamic Graph Plotting with WPFDynamic Graph Plotting with WPF
Dynamic Graph Plotting with WPF
 
2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica2D & 3D Modelling with Mathematica
2D & 3D Modelling with Mathematica
 
Web Developer make the most out of your Database !
Web Developer make the most out of your Database !Web Developer make the most out of your Database !
Web Developer make the most out of your Database !
 
AI02_Python (cont.).pptx
AI02_Python (cont.).pptxAI02_Python (cont.).pptx
AI02_Python (cont.).pptx
 

Más de Andrea Antonello

Smash & Geopaparazzi - State of the art 2021
Smash & Geopaparazzi - State of the art 2021Smash & Geopaparazzi - State of the art 2021
Smash & Geopaparazzi - State of the art 2021Andrea Antonello
 
GEOPAPARAZZI: STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATION
GEOPAPARAZZI: STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATIONGEOPAPARAZZI: STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATION
GEOPAPARAZZI: STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATIONAndrea Antonello
 
GEOPAPARAZZI STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATION
GEOPAPARAZZI STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATIONGEOPAPARAZZI STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATION
GEOPAPARAZZI STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATIONAndrea Antonello
 
Geopaparazzi Survey Server workshop
Geopaparazzi Survey Server workshopGeopaparazzi Survey Server workshop
Geopaparazzi Survey Server workshopAndrea Antonello
 
Geopaparazzi Survey Server Installation
Geopaparazzi Survey Server InstallationGeopaparazzi Survey Server Installation
Geopaparazzi Survey Server InstallationAndrea Antonello
 
Modelling natural hazards in gvSIG with the HortonMachine plugins
Modelling natural hazards in gvSIG with the HortonMachine pluginsModelling natural hazards in gvSIG with the HortonMachine plugins
Modelling natural hazards in gvSIG with the HortonMachine pluginsAndrea Antonello
 
GEOPAPARAZZI: STATE OF THE ART
GEOPAPARAZZI: STATE OF THE ARTGEOPAPARAZZI: STATE OF THE ART
GEOPAPARAZZI: STATE OF THE ARTAndrea Antonello
 
Geopaparazzi - NEVER OUT OF DATA IN THE FIELD
Geopaparazzi - NEVER OUT OF DATA IN THE FIELDGeopaparazzi - NEVER OUT OF DATA IN THE FIELD
Geopaparazzi - NEVER OUT OF DATA IN THE FIELDAndrea Antonello
 
The HortonMachine, for data analysis to help scientists... and not only
The HortonMachine, for data analysis to help scientists... and not onlyThe HortonMachine, for data analysis to help scientists... and not only
The HortonMachine, for data analysis to help scientists... and not onlyAndrea Antonello
 
Geopaparazzi & gvSIG Mobile - state of the art
Geopaparazzi & gvSIG Mobile - state of the artGeopaparazzi & gvSIG Mobile - state of the art
Geopaparazzi & gvSIG Mobile - state of the artAndrea Antonello
 
Foss4g2016 Geopaparazzi Workshop
Foss4g2016 Geopaparazzi WorkshopFoss4g2016 Geopaparazzi Workshop
Foss4g2016 Geopaparazzi WorkshopAndrea Antonello
 
New tools for LiDAR, forestry, river management and hydro-geomorphology in gvSIG
New tools for LiDAR, forestry, river management and hydro-geomorphology in gvSIGNew tools for LiDAR, forestry, river management and hydro-geomorphology in gvSIG
New tools for LiDAR, forestry, river management and hydro-geomorphology in gvSIGAndrea Antonello
 
Digital field mapping with Geopaparazzi and gvSIG
Digital field mapping with Geopaparazzi and gvSIGDigital field mapping with Geopaparazzi and gvSIG
Digital field mapping with Geopaparazzi and gvSIGAndrea Antonello
 
Geopaparazzi, history of a digital mapping kid
Geopaparazzi, history of a digital mapping kidGeopaparazzi, history of a digital mapping kid
Geopaparazzi, history of a digital mapping kidAndrea Antonello
 
Geopaparazzi, state of the art
Geopaparazzi, state of the artGeopaparazzi, state of the art
Geopaparazzi, state of the artAndrea Antonello
 
Geographic scripting in uDig
Geographic scripting in uDigGeographic scripting in uDig
Geographic scripting in uDigAndrea Antonello
 
LESTO - a GIS toolbox for LiDAR empowered sciences
LESTO - a GIS toolbox for LiDAR empowered sciencesLESTO - a GIS toolbox for LiDAR empowered sciences
LESTO - a GIS toolbox for LiDAR empowered sciencesAndrea Antonello
 
04 Geographic scripting in uDig - halfway between user and developer
04 Geographic scripting in uDig - halfway between user and developer04 Geographic scripting in uDig - halfway between user and developer
04 Geographic scripting in uDig - halfway between user and developerAndrea Antonello
 
03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developerAndrea Antonello
 
02 Geographic scripting in uDig - halfway between user and developer
02 Geographic scripting in uDig - halfway between user and developer02 Geographic scripting in uDig - halfway between user and developer
02 Geographic scripting in uDig - halfway between user and developerAndrea Antonello
 

Más de Andrea Antonello (20)

Smash & Geopaparazzi - State of the art 2021
Smash & Geopaparazzi - State of the art 2021Smash & Geopaparazzi - State of the art 2021
Smash & Geopaparazzi - State of the art 2021
 
GEOPAPARAZZI: STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATION
GEOPAPARAZZI: STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATIONGEOPAPARAZZI: STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATION
GEOPAPARAZZI: STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATION
 
GEOPAPARAZZI STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATION
GEOPAPARAZZI STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATIONGEOPAPARAZZI STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATION
GEOPAPARAZZI STATE OF THE ART OF THE DIGITAL FIELD MAPPING APPLICATION
 
Geopaparazzi Survey Server workshop
Geopaparazzi Survey Server workshopGeopaparazzi Survey Server workshop
Geopaparazzi Survey Server workshop
 
Geopaparazzi Survey Server Installation
Geopaparazzi Survey Server InstallationGeopaparazzi Survey Server Installation
Geopaparazzi Survey Server Installation
 
Modelling natural hazards in gvSIG with the HortonMachine plugins
Modelling natural hazards in gvSIG with the HortonMachine pluginsModelling natural hazards in gvSIG with the HortonMachine plugins
Modelling natural hazards in gvSIG with the HortonMachine plugins
 
GEOPAPARAZZI: STATE OF THE ART
GEOPAPARAZZI: STATE OF THE ARTGEOPAPARAZZI: STATE OF THE ART
GEOPAPARAZZI: STATE OF THE ART
 
Geopaparazzi - NEVER OUT OF DATA IN THE FIELD
Geopaparazzi - NEVER OUT OF DATA IN THE FIELDGeopaparazzi - NEVER OUT OF DATA IN THE FIELD
Geopaparazzi - NEVER OUT OF DATA IN THE FIELD
 
The HortonMachine, for data analysis to help scientists... and not only
The HortonMachine, for data analysis to help scientists... and not onlyThe HortonMachine, for data analysis to help scientists... and not only
The HortonMachine, for data analysis to help scientists... and not only
 
Geopaparazzi & gvSIG Mobile - state of the art
Geopaparazzi & gvSIG Mobile - state of the artGeopaparazzi & gvSIG Mobile - state of the art
Geopaparazzi & gvSIG Mobile - state of the art
 
Foss4g2016 Geopaparazzi Workshop
Foss4g2016 Geopaparazzi WorkshopFoss4g2016 Geopaparazzi Workshop
Foss4g2016 Geopaparazzi Workshop
 
New tools for LiDAR, forestry, river management and hydro-geomorphology in gvSIG
New tools for LiDAR, forestry, river management and hydro-geomorphology in gvSIGNew tools for LiDAR, forestry, river management and hydro-geomorphology in gvSIG
New tools for LiDAR, forestry, river management and hydro-geomorphology in gvSIG
 
Digital field mapping with Geopaparazzi and gvSIG
Digital field mapping with Geopaparazzi and gvSIGDigital field mapping with Geopaparazzi and gvSIG
Digital field mapping with Geopaparazzi and gvSIG
 
Geopaparazzi, history of a digital mapping kid
Geopaparazzi, history of a digital mapping kidGeopaparazzi, history of a digital mapping kid
Geopaparazzi, history of a digital mapping kid
 
Geopaparazzi, state of the art
Geopaparazzi, state of the artGeopaparazzi, state of the art
Geopaparazzi, state of the art
 
Geographic scripting in uDig
Geographic scripting in uDigGeographic scripting in uDig
Geographic scripting in uDig
 
LESTO - a GIS toolbox for LiDAR empowered sciences
LESTO - a GIS toolbox for LiDAR empowered sciencesLESTO - a GIS toolbox for LiDAR empowered sciences
LESTO - a GIS toolbox for LiDAR empowered sciences
 
04 Geographic scripting in uDig - halfway between user and developer
04 Geographic scripting in uDig - halfway between user and developer04 Geographic scripting in uDig - halfway between user and developer
04 Geographic scripting in uDig - halfway between user and developer
 
03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer
 
02 Geographic scripting in uDig - halfway between user and developer
02 Geographic scripting in uDig - halfway between user and developer02 Geographic scripting in uDig - halfway between user and developer
02 Geographic scripting in uDig - halfway between user and developer
 

Último

System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTSneha Padhiar
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfBalamuruganV28
 
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESCME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESkarthi keyan
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsResearcher Researcher
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming languageSmritiSharma901052
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Communityprachaibot
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Sumanth A
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionSneha Padhiar
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmDeepika Walanjkar
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodManicka Mamallan Andavar
 

Último (20)

System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdf
 
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESCME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending Actuators
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming language
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Community
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based question
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument method
 

PART 6: FROM GEO INTO YOUR REPORT

  • 1. GEOGRAPHIC SCRIPTING IN GVSIG HALFWAY BETWEEN USER AND DEVELOPER Geoinformation Research Group, Department of Geography University of Potsdam 21-25 November 2016 Andrea Antonello PART 6: FROM GEO INTO YOUR REPORT
  • 2. REPORTING UTILITIES From within gvSIG it is possible also to create charts and documents. Since those functionalities are not completely integrated into the scripting engine, some tricky looking imports are required most of the time. This should not scare the user that want's to generate simple reports in batch mode. In the following examples we will see how to produce charts and spreadsheets.libreoffice
  • 3. OBJECTIVE Let's assume we have to write a report about how min and max average temperature changed between 1983 and 2005 in Germany. We want to create: a shapefile containing polygons connected to the temperatures a chart showing the monthly averages of min and max a spreadsheet with the cleaned up dataset (ex. remove header) The maps have to be in CRS EPSG:32632. The necessary data can be found on the page of Surface meteorology and Solar Energy maintained by NASA: https://eosweb.larc.nasa.gov/sse/
  • 4. SUMMARY OF THE STEPS Before we start, let's create a script with the comments of what we are going to implement: # parse temperature data and extract # a list of information: [lat, lon, tempJan, tempFeb,...] # create the shapefile ## get polygon of Germany ## filter only the data contained in the ## polygon of Germany ## create polygons with attached temperatures ## and write the features into the shapefile # create a chart of the average temperatures # insert the parsed data into a spreadsheet
  • 5. STEP 1: PARSE TEMPERATURE DATA from gvsig import * from gvsig.geom import * def main(*args): # parse temperature data and extract # a dictionary {point: temperaturesList} minPath = "/home/hydrologis/data/potsdam_data/22yr_T10MN" dataFile = open(minPath, "r") lines = dataFile.readlines() dataFile.close() data = {} dataStarted = False for line in lines: if dataStarted or line.startswith("-90"): dataStarted = True lineSplit = line.split(" ") lat = float(lineSplit[0]) lon = float(lineSplit[1]) pointLL = createPoint2D(lon, lat) temperatures = [] for i in range(2, len(lineSplit)-1): # last is avg temperatures.append(float(lineSplit[i])) data[pointLL.convertToWKT()] = temperatures print minData
  • 6. STEP 1: PARSE TEMPERATURE DATA def readData(path): dataFile = open(path, "r") lines = dataFile.readlines() dataFile.close() data = {} dataStarted = False for line in lines: if dataStarted or line.startswith("-90"): dataStarted = True lineSplit = line.split(" ") lat = float(lineSplit[0]) lon = float(lineSplit[1]) pointLL = createPoint2D(lon, lat) temperatures = [] for i in range(2, len(lineSplit)-1): # last is avg temperatures.append(float(lineSplit[i])) data[pointLL.convertToWKT()] = temperatures return data def main(*args): minPath = "/home/hydrologis/data/potsdam_data/22yr_T10MN" maxPath = "/home/hydrologis/data/potsdam_data/22yr_T10MX" minData = readData(minPath) maxData = readData(maxPath) To read also the max temperatures, let's do some code reuse:
  • 7. STEP 2: GET GERMANY # create the shapefile ## get polygon of Germany countriesPath = "/home/hydrologis/data/potsdam_data/ne_10m_admin_0_countries.shp" epsg = "EPSG:4326" countriesLayer = loadLayer("Shape", shpFile=countriesPath, CRS=epsg) features = countriesLayer.features("NAME='Germany'") if features.getCount() != 1: print "ERROR!" return for i in features: germanyFeature = i.getCopy() We can extract the polygon of Germany from a previous exercise: It is very simple to get the points that are contained in the polygon: ## filter only the data contained in the ## polygon of Germany allPointsWKT= minData.keys() allPoints = map(lambda p: createGeometryFromWKT(p), allPointsWKT) pointsInGermany = filter(lambda p: p.intersects(germanyFeature.GEOMETRY), allPoints) print "Points in Germany are", len(pointsInGermany), "while all are", len(allPoints)
  • 8. STEP 3: WRITE THE SHAPEFILE ## create polygons with attached temperatures ## and write the features into the shapefile # create the transform between the original crs and the required newEpsg = "EPSG:32632" crs = getCRS(epsg) newCrs = getCRS(newEpsg) transform = crs.getCT(newCrs) # create the new shapefile and set the editing mode schema = createFeatureType() schema.append("min", "DOUBLE", 8) schema.append("max", "DOUBLE", 8) schema.append("GEOMETRY", "GEOMETRY") schema.get("GEOMETRY").setGeometryType(POLYGON, D2) shape = createShape(schema, prefixname="minmaxtemperatures", CRS=newEpsg) shape.edit() First prepare the re-projection transformation and the output shapefile
  • 9. STEP 3: WRITE THE SHAPEFILE for point in pointsInGermany: x = point.x y = point.y # points all represent the lower left corner # create the polygon considering that pts = [[x,y],[x,y+1],[x+1,y+1],[x+1,y],[x,y]] polygon = createPolygon2D(pts) # reproject the polygon polygon.reProject(transform) # use the point's WKT as key to get the temperature data # from the dictionary minAvg = sum(minData[point.convertToWKT()])/12.0 maxAvg = sum(maxData[point.convertToWKT()])/12.0 shape.append(min=minAvg, max=maxAvg, GEOMETRY=polygon) shape.commit() Then, in the main loop, reproject, average and write:
  • 10. STEP 3: WRITE THE SHAPEFILE # create an interval legend on the min values intervalLegend = VectorialIntervalLegend(POLYGON) intervalLegend.setStartColor(getColorFromRGB(0,0,255)) intervalLegend.setEndColor(getColorFromRGB(255,0,0)) intervalLegend.setIntervalType(1) store = shape.getFeatureStore() intervals = intervalLegend.calculateIntervals(store, "MIN", 5, POLYGON) intervalLegend.setIntervals(intervals) shape.setLegend(intervalLegend) newview = currentProject().createView("Germany View") newview.setProjection(getCRS(newEpsg)) newview.addLayer(shape) newview.addLayer(countriesLayer) newview.showWindow() newview.centerView(shape.fullEnvelope) Style and load the data. Also load the countries layer to check the result. Since (as we already know) the countries layer will be messy outside the 32632 zone, also zoom to the area of Germany:
  • 11. INTERMEDIATE CHECK A this point the script, if run, should produce something like this (countries are styled to only show the borders)
  • 12. STEP 4: CHART THE DATA Charts can be created through the use of the project. Charting in not exactly integrated in the scripting engine, so it requires for the user to import a whole pile of modules. The following are the ones we will make use of in the example: jfreechart from org.jfree.chart import ChartFactory from org.jfree.chart import ChartFrame from org.jfree.data.xy import XYSeriesCollection from org.jfree.data.xy import XYSeries from org.jfree.chart.plot.PlotOrientation import *
  • 13. STEP 4: CHART THE DATA Let's pick the first point of the list of points inside Germany: # create a chart of the average temperatures chartPoint = pointsInGermany[0] minTemperaturesList = minData[chartPoint.convertToWKT()] maxTemperaturesList = maxData[chartPoint.convertToWKT()] Then create the XY chart series, fill them with the temperature data per month and add them to a series collection: dataset = XYSeriesCollection() seriesMin = XYSeries("min") seriesMax = XYSeries("max") for i in range(0, 12): month = i + 1 seriesMin.add(month, minTemperaturesList[i]) seriesMax.add(month, maxTemperaturesList[i]) dataset.addSeries(seriesMin) dataset.addSeries(seriesMax)
  • 14. STEP 4: CHART THE DATA Finally create the chart and display it in a windows: chart = ChartFactory.createXYLineChart( "Temperatures", # chart title "Months", # x axis label "Degrees", #y axis label dataset, VERTICAL, # orientation True, # include legend True, # tooltips? False # URLs? ) # show the chart in a window frame = ChartFrame("Plot test", chart); frame.pack(); frame.setVisible(True);
  • 15. STEP 4: CHART THE DATA The JFreechart window allows the user to zoom and save the current chart as image.
  • 16. STEP 5: SPREADSHEETS To create an modify spreadsheets gvSIG makes use of the project. On its homepage a . In there it is possible to find all the functions that are used in the next example. In the same way as for the charting part, also the spreadsheet part needs some dedicated import statements: jopendocument section is dedicated to the programmer documentation from java.io import File from org.jopendocument.model import OpenDocument from org.jopendocument.dom.spreadsheet import SpreadSheet from org.jopendocument.dom import OOUtils
  • 17. STEP 5: SPREADSHEETS It is simple to set values in the cells by using the column and row as one would do with a matrix: # write the header row in both sheets header = ["lat", "lon", "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"] for i, value in enumerate(header): minSheet.setValueAt(value, i, 0) maxSheet.setValueAt(value, i, 0) Once the imports are in place, it is possible to create a new spreadsheet and add two sheets to it for the min and max table values: # insert the parsed data into a spreadsheet spreadsheetPath = "/home/hydrologis/data/potsdam_data/data_test.ods" # create a spreadsheet spreadSheet = SpreadSheet.create(2, 100, 70000) minSheet = spreadSheet.getSheet(0) minSheet.setName("MIN") maxSheet = spreadSheet.getSheet(1) maxSheet.setName("MAX")
  • 18. STEP 5: SPREADSHEETS Then we can loop the ranges of lat and lon in order to have an ordered list of only the values inside Germany: row = 0 for lat in range(-90, 89): for lon in range(-180, 179): p = createPoint2D(lon, lat) if p in pointsInGermany: row += 1 minSheet.setValueAt(lon, 1, row) minSheet.setValueAt(lat, 0, row) maxSheet.setValueAt(lon, 1, row) maxSheet.setValueAt(lat, 0, row) minTemperaturesList = minData[p.convertToWKT()] maxTemperaturesList = maxData[p.convertToWKT()] for i, t in enumerate(minTemperaturesList): col = i + 2 minSheet.setValueAt(t, col, row) maxSheet.setValueAt(maxTemperaturesList[i], col, row) Finally, save and open the file: outputFile = File(spreadsheetPath) OOUtils.open(spreadSheet.saveAs(outputFile))
  • 19. STEP 5: SPREADSHEETS The resulting file should look like:
  • 20. <license> This work is released under Creative Commons Attribution Share Alike (CC-BY-SA). </license> <sources> Much of the knowledge needed to create this training material has been produced by the sparkling knights of the <a href="http:www.osgeo.org">Osgeo</a>, <a href="http://tsusiatsoftware.net/">JTS</a>, <a href="http://www.jgrasstools.org">JGrasstools</a> and <a href="http:www.gvsig.org">gvSIG</a> communities. Their websites are filled up with learning material that can be use to grow knowledge beyond the boundaries of this set of tutorials. Another essential source has been the Wikipedia project. </sources> <acknowledgments> Particular thanks go to those friends that directly or indirectly helped out in the creation and review of this series of handbooks. Thanks to Antonio Falciano for proofreading the course and Oscar Martinez for the documentation about gvSIG scripting. </acknowledgments> <footer> This tutorial is brought to you by <a href="http:www.hydrologis.com">HydroloGIS</a>. <footer>