版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
测绘编程基础试题及答案1.在Python中,使用`numpy`库生成一个包含10个从0到1均匀分布随机数的数组,正确的代码是()。A.`importnumpyasnp;arr=np.random.rand(10)`
B.`importnumpyasnp;arr=np.random.uniform(0,1,10)`
C.`importnumpyasnp;arr=np.linspace(0,1,10)`
D.`importnumpyasnp;arr=np.arange(0,1,0.1)`答案:(A)2.某测绘程序需要计算两点`(x1,y1)`和`(x2,y2)`之间的欧氏距离,以下代码正确的是()。A.`distance=(x2-x1)2+(y2-y1)2`B.`distance=((x2-x1)2+(y2-y1)2)0.5`C.`distance=math.sqrt((x2-x1)2+(y2-y1)2)`D.`distance=math.pow((x2-x1)2+(y2-y1)2,0.5)`答案:(B)3.在GIS数据处理中,若要将坐标从WGS84(EPSG:4326)转换为Web墨卡托(EPSG:3857),应使用()。A.`pyproj.Transformer.from_crs("EPSG:4326","EPSG:3857")`
B.`pyproj.Transformer.from_crs(4326,3857)`C.`pyproj.Transformer.from_proj("EPSG:4326","EPSG:3857")`
D.`pyproj.Transformer.convert("EPSG:4326","EPSG:3857")`答案:(A)4.某测绘程序需要读取一个GeoJSON文件并提取所有点的坐标,以下代码正确的是()。A.`importjson;data=json.load("file.geojson");coords=
data["features"][0]["geometry"]["coordinates"]`B.`importgeojson;data=geojson.load("file.geojson");coords=
data.features[0].geometry.coordinates`C.`importjson;withopen("file.geojson")asf:data=json.load(f);coords=
[feat["geometry"]["coordinates"]forfeatindata["features"]]`
D.`importgeojson;withopen("file.geojson")asf:data=geojson.loads(f);coords=
data.features.geometry.coordinates`答案:(C)5.在Python中,使用`matplotlib`绘制散点图时,若要设置点的大小为5,颜色为红色,正确的参数是()。A.`plt.scatter(x,y,s=5,c="red")`B.`plt.scatter(x,y,size=5,color="red")`
C.`plt.scatter(x,y,marker=5,color="red")`
D.`plt.scatter(x,y,point_size=5,c="red")`答案:(A)6.某测绘程序需要计算一个多边形的面积,已知顶点坐标为`[(0,0),(1,0),(1,1),(0,1)]`,使用`shapely`库的正确代码是()。
A.`fromshapely.geometryimportPolygon;poly=Polygon([(0,0),(1,0),(1,1),(0,1)]);
area=poly.area`B.`fromshapelyimportPolygon;poly=Polygon([(0,0),(1,0),(1,1),(0,1)]);area=
poly.get_area()`C.`fromshapely.geometryimportPolygon;poly=Polygon([(0,0),(1,0),(1,1),(0,1)]);
area=poly.calculate_area()`D.`fromshapelyimportPolygon;poly=Polygon([(0,0),(1,0),(1,1),(0,1)]);area=
poly.area()`答案:(A)7.在Python中,若要将一个列表`[1,2,3,4]`转换为NumPy数组,正确的代码是()。A.`importnumpyasnp;arr=np.array([1,2,3,4])`
B.`importnumpyasnp;arr=np.list([1,2,3,4])`
C.`importnumpyasnp;arr=np.to_array([1,2,3,4])`
D.`importnumpyasnp;arr=np.convert([1,2,3,4])`答案:(A)8.某测绘程序需要计算两个向量`[1,2,3]`和`[4,5,6]`的点积,以下代码正确的是()。A.`importnumpyasnp;a=np.array([1,2,3]);b=np.array([4,5,6]);dot=np.dot(a,b)`
B.`importnumpyasnp;a=np.array([1,2,3]);b=np.array([4,5,6]);dot=a*b`
C.`importnumpyasnp;a=np.array([1,2,3]);b=np.array([4,5,6]);dot=a+b`
D.`importnumpyasnp;a=np.array([1,2,3]);b=np.array([4,5,6]);dot=a/b`答案:(A)9.在Python中,若要保存一个NumPy数组到文本文件,每行一个数值,正确的代码是()。A.`importnumpyasnp;arr=np.array([1,2,3]);np.savetxt("output.txt",arr,fmt="%d")`
B.`importnumpyasnp;arr=np.array([1,2,3]);np.save("output.txt",arr)`
C.`importnumpyasnp;arr=np.array([1,2,3]);np.writetxt("output.txt",arr)`D.`importnumpyasnp;arr=np.array([1,2,3]);np.tofile("output.txt",arr)`答案:(A)10.某测绘程序需要从CSV文件中读取坐标数据(格式为`x,y`),以下代码正确的是()。A.`importpandasaspd;data=pd.read_csv("coords.csv",header=None,names=["x",
"y"])`B.`importpandasaspd;data=pd.load_csv("coords.csv",columns=["x","y"])`
C.`importpandasaspd;data=pd.read_csv("coords.csv",sep=",",columns=["x","y"])`
D.`importpandasaspd;data=pd.from_csv("coords.csv",names=["x","y"])`答案:(A)11.在Python中,若要使用`geopandas`读取一个Shapefile文件,正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("shapefile.shp")`
B.`importgeopandasasgpd;gdf=gpd.load_shapefile("shapefile.shp")`
C.`importgeopandasasgpd;gdf=gpd.from_file("shapefile.shp")`
D.`importgeopandasasgpd;gdf=gpd.read_shp("shapefile.shp")`答案:(A)12.某测绘程序需要计算一个GeoDataFrame中所有多边形的总面积,已知列名为`"geometry"`,正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");total_area=
gdf["geometry"].area.sum()`B.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");total_area=
gdf.geometry.area.sum()`C.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");total_area=
gdf.calculate_area().sum()`D.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");total_area=
gdf.get_area().sum()`答案:(B)13.在Python中,若要将一个GeoDataFrame保存为GeoJSON文件,正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("input.shp");
gdf.to_file("output.geojson",driver="GeoJSON")`B.`importgeopandasasgpd;gdf=gpd.read_file("input.shp");
gdf.save("output.geojson",format="GeoJSON")`C.`importgeopandasasgpd;gdf=gpd.read_file("input.shp");
gdf.export("output.geojson",driver="GeoJSON")`D.`importgeopandasasgpd;gdf=gpd.read_file("input.shp");
gdf.to_geojson("output.geojson")`答案:(A)14.某测绘程序需要计算两个GeoDataFrame的空间交集,正确的代码是()。
A.`importgeopandasasgpd;gdf1=gpd.read_file("gdf1.shp");gdf2=
gpd.read_file("gdf2.shp");intersection=gpd.overlay(gdf1,gdf2,how="intersection")`
B.`importgeopandasasgpd;gdf1=gpd.read_file("gdf1.shp");gdf2=
gpd.read_file("gdf2.shp");intersection=ersection(gdf2)`
C.`importgeopandasasgpd;gdf1=gpd.read_file("gdf1.shp");gdf2=
gpd.read_file("gdf2.shp");intersection=gdf1.overlay(gdf2,mode="intersection")`
D.`importgeopandasasgpd;gdf1=gpd.read_file("gdf1.shp");gdf2=
gpd.read_file("gdf2.shp");intersection=gpd.spatial_join(gdf1,gdf2,
how="intersection")`答案:(A)15.在Python中,若要使用`folium`库创建一个地图并标记一个点`(40.7128,-74.0060)`,正确的代码是()。A.`importfolium;m=folium.Map(location=[40.7128,-74.0060],zoom_start=12);
folium.Marker([40.7128,-74.0060]).add_to(m);m.save("map.html")`
B.`importfolium;m=folium.Map(location=[40.7128,-74.0060],zoom_start=12);
m.add_marker([40.7128,-74.0060]);m.save("map.html")`C.`importfolium;m=folium.Map(center=[40.7128,-74.0060],zoom=12);
folium.Marker(location=[40.7128,-74.0060]).add_to(m);m.save("map.html")`
D.`importfolium;m=folium.Map(center=[40.7128,-74.0060],zoom=12);
m.marker([40.7128,-74.0060]).add_to(m);m.save("map.html")`答案:(A)16.某测绘程序需要计算一个GeoDataFrame中所有点的平均坐标,已知列名为`"geometry"`,正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("points.shp");avg_x=
gdf["geometry"].x.mean();avg_y=gdf["geometry"].y.mean()`
B.`importgeopandasasgpd;gdf=gpd.read_file("points.shp");avg_x=
gdf.geometry.x.mean();avg_y=gdf.geometry.y.mean()`C.`importgeopandasasgpd;gdf=gpd.read_file("points.shp");avg_x=
gdf.calculate_x().mean();avg_y=gdf.calculate_y().mean()`
D.`importgeopandasasgpd;gdf=gpd.read_file("points.shp");avg_x=
gdf.get_x().mean();avg_y=gdf.get_y().mean()`答案:(B)17.在Python中,若要将一个GeoDataFrame按照`"population"`列分组并计算每组的几何中心,正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("data.shp");centroids=
gdf.groupby("population").geometry.centroid`B.`importgeopandasasgpd;gdf=gpd.read_file("data.shp");centroids=
gdf.groupby("population").calculate_centroid()`C.`importgeopandasasgpd;gdf=gpd.read_file("data.shp");centroids=
gdf.groupby("population").get_centroid()`D.`importgeopandasasgpd;gdf=gpd.read_file("data.shp");centroids=
gdf.groupby("population").geometry.calculate_centroid()`答案:(A)18.某测绘程序需要从PostGIS数据库读取数据,已知连接字符串为`"postgresql://user:password@localhost:5432/db"`,表名为`"cities"`,正确的代码是()。A.`importgeopandasasgpd;fromsqlalchemyimportcreate_engine;engine=
create_engine("postgresql://user:password@localhost:5432/db");gdf=
gpd.read_postgis("SELECT*FROMcities",engine)`B.`importgeopandasasgpd;fromsqlalchemyimportcreate_engine;engine=
create_engine("postgresql://user:password@localhost:5432/db");gdf=
gpd.from_postgis("SELECT*FROMcities",engine)`C.`importgeopandasasgpd;fromsqlalchemyimportcreate_engine;engine=
create_engine("postgresql://user:password@localhost:5432/db");gdf=
gpd.read_sql("SELECT*FROMcities",engine)`D.`importgeopandasasgpd;fromsqlalchemyimportcreate_engine;engine=
create_engine("postgresql://user:password@localhost:5432/db");gdf=
gpd.load_postgis("SELECT*FROMcities",engine)`答案:(A)19.在Python中,若要将一个GeoDataFrame写入PostGIS数据库,已知连接字符串为`"postgresql://user:password@localhost:5432/db"`,表名为`"output"`,正确的代码是()。A.`importgeopandasasgpd;fromsqlalchemyimportcreate_engine;engine=
create_engine("postgresql://user:password@localhost:5432/db");gdf=
gpd.read_file("input.shp");gdf.to_postgis("output",engine,if_exists="replace")`
B.`importgeopandasasgpd;fromsqlalchemyimportcreate_engine;engine=
create_engine("postgresql://user:password@localhost:5432/db");gdf=
gpd.read_file("input.shp");gdf.save_to_postgis("output",engine)`C.`importgeopandasasgpd;fromsqlalchemyimportcreate_engine;engine=
create_engine("postgresql://user:password@localhost:5432/db");gdf=gpd.read_file("input.shp");gdf.export_to_postgis("output",engine)`
D.`importgeopandasasgpd;fromsqlalchemyimportcreate_engine;engine=
create_engine("postgresql://user:password@localhost:5432/db");gdf=
gpd.read_file("input.shp");gdf.to_sql("output",engine,if_exists="replace")`答案:(A)20.某测绘程序需要计算一个GeoDataFrame中所有多边形的边界长度,已知列名为`"geometry"`,正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");lengths=
gdf["geometry"].length`B.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");lengths=
gdf.geometry.calculate_length()`C.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");lengths=
gdf.get_length()`D.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");lengths=
gdf.geometry.boundary.length`答案:(A)21.在Python中,若要使用`rasterio`读取一个GeoTIFF文件并获取其波段数据,正确的代码是()。A.`importrasterio;withrasterio.open("image.tif")assrc;band1=src.read(1)`
B.`importrasterio;withrasterio.open("image.tif")assrc;band1=src.get_band(1)`
C.`importrasterio;withrasterio.open("image.tif")assrc;band1=src.load_band(1)`
D.`importrasterio;withrasterio.open("image.tif")assrc;band1=src.fetch_band(1)`答案:(A)22.某测绘程序需要计算两个GeoDataFrame的空间缓冲区(距离为100米),正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("points.shp");buffered=
gdf.geometry.buffer(100)`B.`importgeopandasasgpd;gdf=gpd.read_file("points.shp");buffered=
gdf.geometry.create_buffer(100)`C.`importgeopandasasgpd;gdf=gpd.read_file("points.shp");buffered=
gdf.geometry.make_buffer(100)`D.`importgeopandasasgpd;gdf=gpd.read_file("points.shp");buffered=
gdf.geometry.add_buffer(100)`答案:(A)23.在Python中,若要将一个GeoDataFrame按照`"category"`列进行空间聚合(统计每类的面积),正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");aggregated=
gdf.dissolve(by="category").area`B.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");aggregated=
gdf.groupby("category").geometry.area.sum()`C.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");aggregated=
gdf.aggregate_by("category").area`D.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");aggregated=
gdf.spatial_aggregate("category").area`答案:(A)24.某测绘程序需要从WFS服务获取数据,已知URL为`"/wfs"`,层名为`"layer"`,正确的代码是()。
A.`importgeopandasasgpd;fromowslib.wfsimportWebFeatureService;wfs=
WebFeatureService("/wfs");response=
wfs.getfeature(typename="layer");gdf=gpd.GeoDataFrame.from_features(response.read())`B.`importgeopandasasgpd;fromowslib.wfsimportWebFeatureService;wfs=
WebFeatureService("/wfs");response=wfs.get_layer("layer");gdf=
gpd.read_features(response)`C.`importgeopandasasgpd;fromowslib.wfsimportWebFeatureService;wfs=
WebFeatureService("/wfs");response=wfs.fetch_feature("layer");
gdf=gpd.from_features(response)`D.`importgeopandasasgpd;fromowslib.wfsimportWebFeatureService;wfs=
WebFeatureService("/wfs");response=wfs.getfeature(layer="layer");gdf=gpd.read_wfs(response)`答案:(A)25.在Python中,若要将一个GeoDataFrame写入KML文件,正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("input.shp");gdf.to_file("output.kml",
driver="KML")`B.`importgeopandasasgpd;gdf=gpd.read_file("input.shp");gdf.save("output.kml",
format="KML")`C.`importgeopandasasgpd;gdf=gpd.read_file("input.shp");gdf.export("output.kml",
driver="KML")`D.`importgeopandasasgpd;gdf=gpd.read_file("input.shp");
gdf.to_kml("output.kml")`答案:(A)26.某测绘程序需要计算一个GeoDataFrame中所有线的总长度,已知列名为`"geometry"`,正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("lines.shp");total_length=
gdf["geometry"].length.sum()`B.`importgeopandasasgpd;gdf=gpd.read_file("lines.shp");total_length=
gdf.geometry.calculate_total_length()`C.`importgeopandasasgpd;gdf=gpd.read_file("lines.shp");total_length=
gdf.get_total_length()`D.`importgeopandasasgpd;gdf=gpd.read_file("lines.shp");total_length=
gdf.geometry.sum_length()`答案:(A)27.在Python中,若要使用`pyproj`计算两个坐标点(WGS84)之间的球面距离(单位:米),正确的代码是()。A.`frompyprojimportGeod;g=Geod(ellps="WGS84");lon1,lat1=-74.0060,40.7128;lon2,lat2=-73.9352,40.7306;_,_,distance=g.inv(lon1,lat1,lon2,lat2);
distance_m=distance`B.`frompyprojimportGeod;g=Geod(ellps="WGS84");lon1,lat1=-74.0060,40.7128;lon2,lat2=-73.9352,40.7306;_,_,distance=g.calculate(lon1,lat1,lon2,
lat2);distance_m=distance`C.`frompyprojimportGeod;g=Geod(ellps="WGS84");lon1,lat1=-74.0060,40.7128;lon2,lat2=-73.9352,40.7306;_,_,distance=g.distance(lon1,lat1,lon2,lat2);
distance_m=distance`D.`frompyprojimportGeod;g=Geod(ellps="WGS84");lon1,lat1=-74.0060,40.7128;lon2,lat2=-73.9352,40.7306;_,_,distance=g.measure(lon1,lat1,lon2,lat2);
distance_m=distance`答案:(A)28.某测绘程序需要从一个GeoDataFrame中筛选出位于另一个GeoDataFrame范围内的要素,正确的代码是()。A.`importgeopandasasgpd;gdf1=gpd.read_file("gdf1.shp");gdf2=
gpd.read_file("gdf2.shp");filtered=gpd.sjoin(gdf1,gdf2,how="inner",
predicate="within")`B.`importgeopandasasgpd;gdf1=gpd.read_file("gdf1.shp");gdf2=
gpd.read_file("gdf2.shp");filtered=ersection(gdf2)`C.`importgeopandasasgpd;gdf1=gpd.read_file("gdf1.shp");gdf2=
gpd.read_file("gdf2.shp");filtered=gdf1.filter_by(gdf2,"within")`
D.`importgeopandasasgpd;gdf1=gpd.read_file("gdf1.shp");gdf2=
gpd.read_file("gdf2.shp");filtered=gdf1.select_where(gdf2,"within")`答案:(A)29.在Python中,若要将一个GeoDataFrame的坐标系从Web墨卡托(EPSG:3857)转换为WGS84(EPSG:4326),正确的代码是()。
A.`importgeopandasasgpd;gdf=gpd.read_file("input.shp",crs="EPSG:3857");gdf=
gdf.to_crs("EPSG:4326")`B.`importgeopandasasgpd;gdf=gpd.read_file("input.shp",crs="EPSG:3857");gdf=
gdf.convert_crs("EPSG:4326")`C.`importgeopandasasgpd;gdf=gpd.read_file("input.shp",crs="EPSG:3857");gdf=
gdf.change_crs("EPSG:4326")`D.`importgeopandasasgpd;gdf=gpd.read_file("input.shp",crs="EPSG:3857");gdf=
gdf.set_crs("EPSG:4326")`答案:(A)30.某测绘程序需要计算一个GeoDataFrame中所有多边形的最小外接矩形,已知列名为`"geometry"`,正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");envelopes=
gdf["geometry"].envelope`B.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");envelopes=
gdf.geometry.calculate_envelope()`C.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");envelopes=
gdf.get_envelope()`D.`importgeopandasasgpd;gdf=gpd.read_file("polygons.shp");envelopes=
gdf.geometry.min_bounding_box()`答案:(A)31.在Python中,若要使用`rasterstats`计算一个GeoDataFrame中每个多边形覆盖的栅格平均值,已知栅格文件为`"elevation.tif"`,正确的代码是()。
A.`fromrasterstatsimportzonal_stats;gdf=gpd.read_file("polygons.shp");stats=
zonal_stats(gdf,"elevation.tif",stats=["mean"])`B.`fromrasterstatsimportzonal_stats;gdf=gpd.read_file("polygons.shp");stats=
zonal_stats(gdf.geometry,"elevation.tif",stats=["mean"])`C.`fromrasterstatsimportzonal_stats;gdf=gpd.read_file("polygons.shp");stats=
zonal_stats(gdf["geometry"],"elevation.tif",stats=["mean"])`D.`fromrasterstatsimportzonal_stats;gdf=gpd.read_file("polygons.shp");stats=
zonal_stats(gdf.to_crs(),"elevation.tif",stats=["mean"])`答案:(C)32.某测绘程序需要从一个GeoDataFrame中随机抽取10%的样本,正确的代码是()。A.`importgeopandasasgpd;gdf=gpd.read_file("data.shp");sample=
gdf.sample(frac=0.1)`B.`importgeopandasasgpd;gdf=gpd.read_file("data.shp");sample=
gdf.random_sample(0.1)`C.`importgeopandasasgpd;gdf=gpd.read_file("data.shp");sample=
gdf.take_sample(0.1)`D.`importgeopandasasgpd;gdf=gpd.read_file("data.shp"
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 工业基础技术 3
- OA系统外包合同
- 中海油员工外包合同
- 京东入职签外包合同
- 企业工程外包合同
- 人才资源外包合同
- 伙房外包合同
- 信息项目外包合同
- 公司临时工外包合同
- 公司要求外包合同
- 儿童用药安全与合理用药
- 人教版八年级物理下册 实验题02 压力压强实验(含答案详解)
- 污染环境的生物修复课件
- 某地块土壤污染状况调查汇报PPT模板框架
- 模拟CMOS集成电路设计课程设计实验报告(二级放大器的设计)
- 儿童感觉统合能力发展评定量表(含原始分与标准分转换表)988
- GB/T 18570.3-2005涂覆涂料前钢材表面处理表面清洁度的评定试验第3部分:涂覆涂料前钢材表面的灰尘评定(压敏粘带法)
- 肝衰竭机制及治疗进展课件
- 回转窑基础知识培训课件
- (名师整理)最新中考语文《非连续性文本阅读》专题复习精品课件
- STAR CCM+培训基础 课件
评论
0/150
提交评论