3.3 Import shp and geodatabase

This commit is contained in:
PeterZhong 2024-09-23 11:41:18 +08:00
parent 14317fea42
commit 8a7c33489d
49 changed files with 2290 additions and 5 deletions

View File

@ -6,6 +6,7 @@
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion> <SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers> <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
</PropertyGroup> </PropertyGroup>

View File

@ -1,4 +1,4 @@
<Window x:Class="GisDevelop_Exp.MainWindow" <Window x:Name="MainWindow1" x:Class="GisDevelop_Exp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -6,11 +6,18 @@
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013" xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
xmlns:local="clr-namespace:GisDevelop_Exp" xmlns:local="clr-namespace:GisDevelop_Exp"
mc:Ignorable="d" mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"> Title="GIS开发实验" Height="450" Width="800">
<Window.Resources> <Window.Resources>
<local:MapViewModel x:Key="MapViewModel" /> <local:MapViewModel x:Key="MapViewModel" />
</Window.Resources> </Window.Resources>
<Grid> <Grid>
<esri:MapView x:Name="MainMapView" Map="{Binding Map, Source={StaticResource MapViewModel}}" /> <Menu x:Name="MenuContainer" Margin="0,0,0,0">
<MenuItem x:Name="Menu_File" Header="文件">
<MenuItem x:Name="Menu_OpenShp" Header="打开Shp" Click="Menu_OpenShp_Click"/>
<MenuItem x:Name="Menu_OpenGeodatabase" Header="打开Geodatabase" Click="Menu_OpenGeodatabase_Click"/>
</MenuItem>
<MenuItem x:Name="Menu_View" Header="视图"/>
</Menu>
<esri:MapView x:Name="MainMapView" Map="{Binding Map, Source={StaticResource MapViewModel}}" Margin="0,19,0,0" />
</Grid> </Grid>
</Window> </Window>

View File

@ -1,4 +1,6 @@
using System; using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Mapping;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -20,9 +22,70 @@ namespace GisDevelop_Exp
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
private FeatureLayer _featureLayer;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
private void Menu_OpenShp_Click(object sender, RoutedEventArgs e)
{
OpenShp();
}
private async void OpenShp()
{
System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog();
fileDialog.Multiselect = true;
fileDialog.Filter = "Shapefile文件(*.shp)|*.shp";
fileDialog.Title = "打开Shapefile文件";
if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
for (int i = 0; i < fileDialog.FileNames.Length; i++)
{
String filePath = fileDialog.FileNames.GetValue(i).ToString();
ShapefileFeatureTable openedFeature = await ShapefileFeatureTable.OpenAsync(filePath);
FeatureLayer opendFeatureLayer = new FeatureLayer(openedFeature);
MainMapView.Map.OperationalLayers.Add(opendFeatureLayer);
await MainMapView.SetViewpointGeometryAsync(opendFeatureLayer.FullExtent);
}
}
}
private async void OpenGeoDatabase()
{
string _slocalGeodatabasePath = "";
Geodatabase _localGeodatabase;
System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog();
fileDialog.Filter = "Geodatabase文件(*.geodatabase)|*.geodatabase";
if(fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
_slocalGeodatabasePath = fileDialog.FileName;
}
if (System.IO.File.Exists(_slocalGeodatabasePath))
{
_localGeodatabase = await Geodatabase.OpenAsync(_slocalGeodatabasePath);
Map geodatabaseMap = new Map();
int beginCount = _localGeodatabase.GeodatabaseFeatureTables.Count - 1;
for (int i = beginCount; i >= 0; i--)
{
GeodatabaseFeatureTable table = _localGeodatabase.GeodatabaseFeatureTables[i];
await table.LoadAsync();
FeatureLayer layer = new FeatureLayer(table);
layer.Name = table.TableName;
geodatabaseMap.OperationalLayers.Add(layer);
_featureLayer = layer;
}
Viewpoint geodatabaseViewPoint = new Viewpoint(_featureLayer.FullExtent);
geodatabaseMap.InitialViewpoint = geodatabaseViewPoint;
MainMapView.Map = geodatabaseMap;
}
}
private void Menu_OpenGeodatabase_Click(object sender, RoutedEventArgs e)
{
OpenGeoDatabase();
}
} }
} }

View File

@ -27,7 +27,7 @@ namespace GisDevelop_Exp
{ {
InitialViewpoint = new Viewpoint(new Envelope(-180, -85, 180, 85, SpatialReferences.Wgs84)), InitialViewpoint = new Viewpoint(new Envelope(-180, -85, 180, 85, SpatialReferences.Wgs84)),
#warning To use ArcGIS location services (including basemaps) specify your API Key access token or require the user to sign in using a valid ArcGIS account. #warning To use ArcGIS location services (including basemaps) specify your API Key access token or require the user to sign in using a valid ArcGIS account.
Basemap = new Basemap(BasemapStyle.ArcGISStreets) Basemap = new Basemap(BasemapStyle.ArcGISTopographic)
}; };
} }

BIN
data/Raster_file/Shasta.tif Normal file

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,35 @@
<PAMDataset>
<Metadata>
<MDI key="DataType">Generic</MDI>
</Metadata>
<Metadata domain="Esri">
<MDI key="PyramidResamplingType">NEAREST</MDI>
</Metadata>
<PAMRasterBand band="1">
<Description>Layer_1</Description>
<Histograms>
<HistItem>
<HistMin>885.5999755859375</HistMin>
<HistMax>1214.5</HistMax>
<BucketCount>256</BucketCount>
<IncludeOutOfRange>1</IncludeOutOfRange>
<Approximate>0</Approximate>
<HistCounts>64|113|170|363|517|575|606|634|648|2586|2205|21153|11979|13431|18386|16572|21362|26377|30575|19807|18504|26665|27815|20691|21741|19662|15912|9589|8412|7506|8556|7872|7735|7131|5378|4143|4385|4368|4079|3448|3839|4025|4996|4400|4537|4696|5008|5064|5327|6803|5721|5547|5683|5380|5555|5419|5683|8004|6944|6889|6725|6933|6897|6964|7342|9931|8004|8404|7667|8380|8489|8447|8566|9597|8278|8125|8231|8499|7765|8553|9426|8415|8317|8439|8673|8672|8787|8725|9082|8577|8624|8565|8786|8873|8789|8968|10240|8480|9239|9163|9266|9158|9198|9297|12007|9612|9559|8877|9385|9345|9441|10551|10319|10152|10191|10013|10041|9123|9691|13412|16577|15431|13719|13432|13283|12589|11606|17649|20538|17435|16391|16539|16864|15578|14867|17692|15108|13324|13591|14254|12935|12429|14317|18196|17437|15904|14461|14617|13973|13355|15903|17214|16227|15534|16048|13165|11125|11678|13444|11901|11658|11326|10881|10131|9794|9365|11367|11060|9484|9417|9145|8737|8381|9067|9198|9055|8401|9027|8497|8441|8213|9149|8517|8615|13938|8786|7876|8134|8068|9983|8970|9054|8931|9088|8681|8667|7770|11135|9946|9458|9326|9121|8953|8672|9500|10313|10594|10129|10058|9236|8665|8646|9893|9393|9481|8827|9635|9566|9065|8637|12853|11625|11657|15142|19224|23209|35353|64053|119666|122004|94968|79547|93222|63667|65661|48367|107234|65083|64997|53280|49566|35966|34611|44049|61492|34693|25111|37165|25106|18252|9917|8243|8517|5384|1943|40</HistCounts>
</HistItem>
</Histograms>
<Metadata>
<MDI key="LAYER_TYPE">athematic</MDI>
<MDI key="RepresentationType">ATHEMATIC</MDI>
<MDI key="STATISTICS_COVARIANCES">9628.572489401928</MDI>
<MDI key="STATISTICS_EXCLUDEDVALUES"></MDI>
<MDI key="STATISTICS_MAXIMUM">1214.5</MDI>
<MDI key="STATISTICS_MEAN">1097.3114238437</MDI>
<MDI key="STATISTICS_MEDIAN">0</MDI>
<MDI key="STATISTICS_MINIMUM">885.59997558594</MDI>
<MDI key="STATISTICS_MODE">0</MDI>
<MDI key="STATISTICS_SKIPFACTORX">1</MDI>
<MDI key="STATISTICS_SKIPFACTORY">1</MDI>
<MDI key="STATISTICS_STDDEV">98.125289754486</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>

Binary file not shown.

View File

@ -0,0 +1,6 @@
5.0000000000
0.0000000000
0.0000000000
-5.0000000000
534193.6310411390
3865550.5373846227

Binary file not shown.

View File

@ -0,0 +1,30 @@
<PAMDataset>
<Metadata>
<MDI key="DataType">Generic</MDI>
</Metadata>
<Metadata domain="Esri">
<MDI key="PyramidResamplingType">NEAREST</MDI>
</Metadata>
<PAMRasterBand band="1">
<Histograms>
<HistItem>
<HistMin>785.1702880859375</HistMin>
<HistMax>1175</HistMax>
<BucketCount>256</BucketCount>
<IncludeOutOfRange>1</IncludeOutOfRange>
<Approximate>0</Approximate>
<HistCounts>25|71|115|136|143|166|182|219|235|236|185|199|239|268|306|397|511|525|576|614|640|664|778|932|995|1049|1071|1108|1156|1303|1154|1155|1186|1202|1246|1496|1452|1452|1496|1567|1575|1617|2287|1970|2015|1955|2090|2225|3318|2736|2988|3038|3162|3096|3143|3990|3832|3733|3819|3823|4137|4635|5400|4786|4985|5175|5215|5333|5840|5008|5292|6226|5849|6105|6740|9086|7759|7681|7519|7264|7288|8548|8106|8181|8523|7865|8051|8412|9840|8818|9358|10156|9437|9730|10979|9896|10032|10195|10131|9835|9936|11204|9779|9922|10550|9859|10305|13545|13409|13463|14205|13257|12264|11957|16885|16694|16211|16893|15842|15744|17841|20975|21622|21802|23440|21490|20195|25954|28760|25339|23720|21459|20376|20898|24570|23376|22236|22767|21376|20701|25619|26632|26326|25088|23403|21209|19463|29188|26036|24829|26001|24587|23057|25591|28737|26343|26095|28272|28016|25979|31683|29407|27253|29136|29332|27387|27419|30755|29486|29505|33707|33798|31854|46949|43240|36408|35238|32933|31488|33225|34162|32734|28350|36760|33322|31508|34104|31418|28303|35417|35177|32682|33244|33197|31466|27525|40835|37422|33888|37829|33888|30083|30860|29524|27844|25007|30511|26713|25620|35529|28240|22976|26782|26312|23909|24363|33359|28555|25340|37767|30043|24554|29541|29058|28648|35973|35460|28310|27558|31025|29849|24203|27237|25587|22789|25667|27145|20689|18655|20145|19938|20250|14020|14550|12653|11579|11661|11162|11559|11191|10458|10845|14366|6738|774|228</HistCounts>
</HistItem>
</Histograms>
<Metadata>
<MDI key="RepresentationType">ATHEMATIC</MDI>
<MDI key="STATISTICS_COVARIANCES">5430.094592014742</MDI>
<MDI key="STATISTICS_MAXIMUM">1175</MDI>
<MDI key="STATISTICS_MEAN">1045.8027149283</MDI>
<MDI key="STATISTICS_MINIMUM">785.17028808594</MDI>
<MDI key="STATISTICS_SKIPFACTORX">1</MDI>
<MDI key="STATISTICS_SKIPFACTORY">1</MDI>
<MDI key="STATISTICS_STDDEV">73.689175541695</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>

Binary file not shown.

BIN
data/Raster_file/srtm.tiff Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
10.0000000000
0.0000000000
0.0000000000
-10.0000000000
467990.0000000000
4441480.0000000000

Binary file not shown.

View File

@ -0,0 +1,30 @@
<PAMDataset>
<Metadata>
<MDI key="DataType">Generic</MDI>
</Metadata>
<Metadata domain="Esri">
<MDI key="PyramidResamplingType">NEAREST</MDI>
</Metadata>
<PAMRasterBand band="1">
<Histograms>
<HistItem>
<HistMin>1591</HistMin>
<HistMax>2567.199951171875</HistMax>
<BucketCount>256</BucketCount>
<IncludeOutOfRange>1</IncludeOutOfRange>
<Approximate>0</Approximate>
<HistCounts>858|2763|2680|6622|13442|13301|12561|16146|16379|13288|25795|30526|22608|22984|28398|21308|17640|23098|18568|14460|20456|20664|12458|14973|13974|11229|11143|10008|8074|7918|8600|6126|5652|6142|4707|4098|4516|3726|3127|3832|3634|3264|3984|3709|3495|4008|4129|3668|4032|4204|3776|4087|4541|4486|4479|5049|4778|4658|5458|5574|5285|5923|5936|5788|6462|6918|6373|6887|6984|6398|6597|7234|6838|6620|7701|7637|7399|8358|8301|7685|8374|8894|8009|8442|9088|8588|8450|9414|9468|8598|9358|8962|8390|8962|8767|8171|8903|9531|8724|9545|9952|9000|9458|10063|9437|9097|10165|9624|8564|9584|8732|7644|8301|8706|7566|8137|8587|7933|7846|8680|8254|7657|8303|8128|7546|7837|7647|7023|7659|8176|7388|8104|8165|7114|7330|7664|7371|6846|7584|7067|6375|7431|7253|6517|6637|6624|5613|5859|6017|5041|5030|5202|4807|4467|4566|4341|3981|4192|4049|3633|3925|3812|3312|3784|3665|3276|3462|3553|3364|3423|3730|3357|3154|3380|3077|2793|2874|2909|2489|2654|2788|2378|2465|2522|2378|2323|2469|2473|2324|2408|2183|2180|2290|2214|1981|1993|2020|1769|1759|1870|1661|1617|1729|1521|1475|1378|1040|896|925|977|844|753|721|578|577|584|514|480|479|467|379|384|387|389|405|393|323|359|325|304|295|281|244|224|280|251|240|260|197|211|209|177|176|187|203|145|111|93|60|51|40|27|10|11|11|1</HistCounts>
</HistItem>
</Histograms>
<Metadata>
<MDI key="RepresentationType">ATHEMATIC</MDI>
<MDI key="STATISTICS_COVARIANCES">47015.96445198142</MDI>
<MDI key="STATISTICS_MAXIMUM">2567.1999511719</MDI>
<MDI key="STATISTICS_MEAN">1900.1096195905</MDI>
<MDI key="STATISTICS_MINIMUM">1591</MDI>
<MDI key="STATISTICS_SKIPFACTORX">1</MDI>
<MDI key="STATISTICS_SKIPFACTORY">1</MDI>
<MDI key="STATISTICS_STDDEV">216.83165002366</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>

Binary file not shown.

View File

@ -0,0 +1,6 @@
10.0000000000
0.0000000000
0.0000000000
-10.0000000000
524030.0000000000
5184190.0000000000

BIN
data/Raster_file/usgs10.tif Normal file

Binary file not shown.

View File

@ -0,0 +1,30 @@
<PAMDataset>
<Metadata>
<MDI key="DataType">Generic</MDI>
</Metadata>
<Metadata domain="Esri">
<MDI key="PyramidResamplingType">NEAREST</MDI>
</Metadata>
<PAMRasterBand band="1">
<Histograms>
<HistItem>
<HistMin>465</HistMin>
<HistMax>1828</HistMax>
<BucketCount>256</BucketCount>
<IncludeOutOfRange>1</IncludeOutOfRange>
<Approximate>0</Approximate>
<HistCounts>8401|64|1039|297|228|285|261|232|278|221|225|265|202|242|267|209|230|298|268|247|300|292|296|297|281|255|326|254|349|237|275|313|275|263|332|292|295|323|293|289|544|497|469|507|358|286|401|333|288|363|284|271|306|254|247|287|210|252|208|248|303|267|243|328|259|262|298|233|216|267|235|229|264|227|208|263|225|252|319|256|288|371|295|282|340|274|302|252|268|301|274|258|342|268|256|324|279|285|380|348|420|537|480|509|507|394|431|543|430|433|628|522|524|620|596|836|699|738|990|858|786|939|812|771|830|713|719|825|647|711|787|626|590|838|662|660|827|767|787|863|758|714|778|595|733|628|575|681|579|557|617|556|622|772|599|625|782|662|569|724|594|501|632|583|594|595|490|443|512|351|444|391|356|462|397|478|506|418|411|506|379|387|472|382|316|439|378|329|382|307|295|322|294|290|329|255|264|288|243|258|214|212|223|188|201|217|182|177|227|198|180|243|222|218|272|207|215|235|188|192|207|157|170|201|201|188|226|175|186|164|159|211|169|147|190|155|137|154|119|121|141|136|119|132|102|100|159|118|106|78|63|44|19|16|13|2</HistCounts>
</HistItem>
</Histograms>
<Metadata>
<MDI key="RepresentationType">THEMATIC</MDI>
<MDI key="STATISTICS_COVARIANCES">125131.3687639</MDI>
<MDI key="STATISTICS_MAXIMUM">1828</MDI>
<MDI key="STATISTICS_MEAN">1068.0229824561</MDI>
<MDI key="STATISTICS_MINIMUM">465</MDI>
<MDI key="STATISTICS_SKIPFACTORX">1</MDI>
<MDI key="STATISTICS_SKIPFACTORY">1</MDI>
<MDI key="STATISTICS_STDDEV">353.73912529419</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>

Binary file not shown.

View File

@ -0,0 +1 @@
UTF-8

Binary file not shown.

View File

@ -0,0 +1,6 @@
10.0000000000
0.0000000000
0.0000000000
-10.0000000000
524030.0000000000
5184190.0000000000

Binary file not shown.

View File

@ -0,0 +1,23 @@
<PAMDataset>
<PAMRasterBand band="1">
<Histograms>
<HistItem>
<HistMin>465</HistMin>
<HistMax>1825.5555419922</HistMax>
<BucketCount>256</BucketCount>
<IncludeOutOfRange>1</IncludeOutOfRange>
<Approximate>0</Approximate>
<HistCounts>8298|486|441|360|288|342|324|279|198|225|315|189|279|189|297|234|252|243|252|306|324|243|279|261|297|243|297|252|288|342|234|279|369|234|369|252|369|279|351|360|396|468|450|504|396|297|360|306|288|405|252|297|270|351|225|279|216|261|252|162|414|252|234|270|216|279|252|315|288|153|234|261|198|261|207|216|297|324|315|270|180|333|324|252|306|306|315|378|288|180|270|225|288|324|297|369|342|297|342|396|324|405|486|603|477|351|468|468|450|531|567|531|540|630|576|783|648|873|837|945|792|828|864|792|729|774|819|747|666|675|756|711|702|729|666|675|792|801|675|819|873|657|792|666|693|684|558|612|639|603|540|531|702|657|648|675|693|729|621|603|576|594|666|612|585|495|549|459|441|423|459|351|369|486|459|414|441|405|558|396|477|315|450|405|324|378|414|450|261|351|261|387|333|225|315|243|315|288|216|225|252|261|198|135|252|171|252|189|162|225|216|207|198|243|270|189|279|162|216|198|198|171|171|153|243|243|180|144|162|180|243|135|162|189|180|153|126|171|162|90|135|144|153|72|135|117|126|126|117|90|54|72|27|9|9|9</HistCounts>
</HistItem>
</Histograms>
<Metadata>
<MDI key="STATISTICS_COVARIANCES">125036.5029836591</MDI>
<MDI key="STATISTICS_MAXIMUM">1825.5555419922</MDI>
<MDI key="STATISTICS_MEAN">1068.0229825605</MDI>
<MDI key="STATISTICS_MINIMUM">465</MDI>
<MDI key="STATISTICS_SKIPFACTORX">1</MDI>
<MDI key="STATISTICS_SKIPFACTORY">1</MDI>
<MDI key="STATISTICS_STDDEV">353.60500983959</MDI>
</Metadata>
</PAMRasterBand>
</PAMDataset>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xml:lang="zh"><Esri><CreaDate>20181217</CreaDate><CreaTime>22451600</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><DataProperties><lineage><Process ToolSource="c:\program files (x86)\arcgis\desktop10.4\ArcToolbox\Toolboxes\Spatial Analyst Tools.tbx\BlockStatistics" Date="20181217" Time="224516">BlockStatistics usgs10 E:\teaching\16GIS二次开发\experiments\Exp8\Raster_file\usgs10_2.tif "Rectangle 3 3 CELL" MEAN DATA</Process></lineage></DataProperties></Esri></metadata>

BIN
data/Shp数据/XZQ_D.dbf Normal file

Binary file not shown.

BIN
data/Shp数据/XZQ_D.ebb Normal file

Binary file not shown.

BIN
data/Shp数据/XZQ_D.ed1 Normal file

Binary file not shown.

BIN
data/Shp数据/XZQ_D.eq1 Normal file

Binary file not shown.

1
data/Shp数据/XZQ_D.prj Normal file
View File

@ -0,0 +1 @@
GEOGCS["Xian_1980",DATUM["Xian_1980",SPHEROID["<custom>",6378140.0,298.2569999999957]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]

BIN
data/Shp数据/XZQ_D.sbn Normal file

Binary file not shown.

BIN
data/Shp数据/XZQ_D.sbx Normal file

Binary file not shown.

BIN
data/Shp数据/XZQ_D.shp Normal file

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

BIN
data/Shp数据/XZQ_D.shx Normal file

Binary file not shown.

BIN
data/Tif data/RGB.tiff Normal file

Binary file not shown.

BIN
data/Tif data/wsiearth.aux Normal file

Binary file not shown.

BIN
data/Tif data/wsiearth.prj Normal file

Binary file not shown.

BIN
data/Tif data/wsiearth.rrd Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
0.0359281435
0.0000000000
0.0000000000
-0.0359281437
-179.9820349282
89.9820359281

BIN
data/Tif data/wsiearth.tif Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
doc/实验一 地图.pdf Normal file

Binary file not shown.